42

How to I set the bootable partition using the command line in parted?

Ideally I would like a numbered list so I can select which partition to boot from easily.

1
  • 2
    How to set a partition flag is explained in the manual and should be a trivial task... You can't have numbered lists when you set a flag but you can always print the device layout (which is a numbered list) and inspect it before setting any flags. Feb 8, 2017 at 12:24

3 Answers 3

41

I use fdisk. before to apply this I recommend to work with a live CD or USB and back up your data.

First check if any bootable partition is present like in my system wich "/dev/sda1" is the bootable partition :

fdisk -l /dev/sda                                                      

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00003256

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1    *       2048   959991807   479994880   83  Linux
/dev/sda2       959993854   976766975     8386561    5  Extended
/dev/sda5       959993856   976766975     8386560   82  Linux swap / Solaris

If there is not any boot partition do like this with root login :

fdisk  /dev/sda
Command (m for help): m

Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): a
Partition number (1-5): 

You've to type 1 if you want to make bootable the partition 1 or and following 2 if you want to make bootable the second partition etc...

and aply the modification with "w" like this

Command (m for help): w

For modify the table of your disk and make the desired partition bootable.

In hoping that help

2
  • 16
    fdisk appears to not have bootable flag option any longer ... on archlinux install attempt on 20190712 Jul 13, 2019 at 14:20
  • With fdisk I created the System EFI partition and it automatically had the bootable flag with GPT which I could see with parted1, even though I could not set it manually any more. Possibly choosing the correct partition type is sufficient.
    – mateuszb
    Mar 8, 2020 at 13:34
32

With the print command you ge the partition number (first column). Let us say it is 1. To make it bootable:

(parted) set 1 boot on
4
  • Worth noting that you can do this in the GUI very easily; right click the partition you want, flags, click boot. Mar 27, 2018 at 3:28
  • 4
    @robert, Thank you for the right answer to the question!
    – Ashfaq
    Jun 14, 2019 at 8:33
  • 1
    Interactionless one-liner form: parted /dev/sdX set 1 boot on. Prints: Information: You may need to update /etc/fstab.
    – cbugk
    Dec 30, 2022 at 13:41
  • what do you mean by print command? just print? parted print? May 24, 2023 at 7:23
2

OS X https://qwiek.wordpress.com/ "fdisk" then flag 1 to make first partition bootable.

2
  • The question cannot be about OS X, as it is about Linux !
    – Quidam
    Apr 27, 2020 at 11:38
  • BSD is unix? :)
    – rogerdpack
    May 16, 2020 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .