How to set or change boot partition flag on Linux

The boot partition flag is used to indicate that an MBR partition is bootable. Although MBR has been superseded by GUID Partition Table in recent years, MBR is still very prevalent across many systems. The boot loader resides on a bootable partition and is what tells your system where to look for the operating system.

In this tutorial, you will find the step by step instructions to set or change the boot partition flag on a Linux system via command line and GUI.

In this tutorial you will learn:

  • How to set bootable partition flag via command line or GUI
How to set or change boot partition flag on Linux
How to set or change boot partition flag on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software MBR, fdisk, Disks GUI app
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to set or change boot partition flag on Linux step by step instructions




Use the approrpriate set of instructions below, depending on whether you want to change the boot partition flag via command line or GUI. The command line method is sure to work across any Linux distro.

Set/change boot partition flag via command line

  1. Open up a terminal and use the following fdisk command to see which of your partitions currently has the bootable flag. This must be executed with root permissions.
    $ sudo fdisk -l
    

    In the output, you will see which partitions have a bootable flag. See the screenshot below for reference.

    fdisk indicates with an asterisk which partition has the bootable flag
    fdisk indicates with an asterisk which partition has the bootable flag
  2. To turn a bootable flag on or off, select your drive in fdisk. We will be using drive /dev/sdX as an example.
    $ sudo fdisk /dev/sdX
    
  3. Enter the a option to toggle a bootable flag.
    Command (m for help): a
    



  4. Next you will be asked to select a partition number. Enter your selection for the partition that you would like to toggle the boot flag on or off for.
    Partition number:
    
    Setting bootable flag on a partition in Linux
    Setting bootable flag on a partition in Linux
  5. Finally, issue the w command to write the changes you have just made. fdisk will then automatically exit.
    Command (m for help): w
    The partition table has been altered.
    Syncing disks.
    

That’s all there is to it. Repeat the steps as necessary if you need to toggle another disk partition’s bootable flag on or off. Check the fdisk -l output to verify changes that you make.

Set/change boot partition flag via GUI

These steps are going to vary depending on which distro and desktop environment you are using. However, most or all systems have a disk management application similar to the one we are using below, so you should be able to follow along. We are using GNOME on Ubuntu in these steps.

  1. Start by opening your disk management application. It is simply called Disks on our system.
    Opening disk management application
    Opening disk management application
  2. Now highlight the partition you want to edit, click the cog wheel, and click Edit Partition.

    Select option to edit partition
    Select option to edit partition



  3. Finally, toggle the bootable flag on or off. Then you can finalize your changes with the “Change” button and close the disk management application.
    Toggle bootable flag on or off via GUI
    Toggle bootable flag on or off via GUI

Closing Thoughts

In this tutorial, we saw how to set or change the boot partition flag on Linux. This can be done via command line or GUI, although the instructions for GUI will vary depending on your system. This is only helpful for MBR disks, which are becoming outdated in favor of GUID but it is still common to find them.



Comments and Discussions
Linux Forum