Ubuntu HowTo: Change Hard Disk Boot order without using BIOS settings

Original Source Link

Sorry for the duplicate question but I have read these links:

But none of above links solved my problem.

Actually, the question is same, but the meaning is different. I want to change disk boot order on my computer (which disk will boot first, second and third. like CD-ROM -> Hard-Disk -> USB- Drive). I can do it using BIOS settings, but I want to change disk boot order using Ubuntu.

When I type sudo fdisk -l on the terminal, I get the following result.

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors

Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E7225B99-3850-4E61-8D35-D3D269A42F1A

Device          Start        End   Sectors   Size Type
/dev/sda1        2048  421529599 421527552   201G Microsoft basic data
/dev/sda2   421529600  840959999 419430400   200G Microsoft basic data
/dev/sda3   840960000  841881599    921600   450M Windows recovery environment
/dev/sda4   841881600  842086399    204800   100M EFI System
/dev/sda5   842086400  842119167     32768    16M Microsoft reserved
/dev/sda6   843057152  864028671  20971520    10G Microsoft basic data
/dev/sda7   864028672 1015023615 150994944    72G Linux filesystem
/dev/sda8  1015023616 1224738815 209715200   100G Microsoft basic data
/dev/sda9  1226835968 1436551167 209715200   100G Microsoft basic data
/dev/sda10 1438648320 1635380309 196731990  93.8G Microsoft basic data
/dev/sda11 1635381248 1710135295  74754048  35.7G Linux filesystem
/dev/sda12 1710135296 1953523711 243388416 116.1G Linux filesystem




Disk /dev/sdb: 14.9 GiB, 16005464064 bytes, 31260672 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
Disklabel type: dos
Disk identifier: 0x05fec185

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *     2048 31260671 31258624 14.9G  c W95 FAT32 (LBA)

Here, currently, I have two disks One internal HDD (1 TB) and second external USB Drive (14.9 GB).

Is there any command in Linux?

Yes there is for EFI: efibootmgr

$ efibootmgr
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,0044,004E,004F
Boot0000* ubuntu
Boot0044* UEFI OS
Boot004E* ubuntu
Boot004F* CD/DVD Drive 

… shows the current boot order. efibootmgr -v (more details, including GUID) to list them:

BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000
Boot0000* ubuntu    HD(1,GPT,066aad32-119e-407c-af62-64ce08918c66,0x800,0x17800)/File(EFIubuntushimx64.efi)
Boot0044* UEFI OS   HD(1,GPT,066aad32-119e-407c-af62-64ce08918c66,0x800,0x17800)/File(EFIBOOTBOOTX64.EFI)
Boot004E* ubuntu    HD(1,GPT,066aad32-119e-407c-af62-64ce08918c66,0x800,0x17800)/File(EFIUbuntugrubx64.efi)
Boot004F* CD/DVD Drive  BBS(CDROM,,0x0)..GO..NO........o.M.A.T.S.H.I.T.A.D.V.D.-.R.A.M. .U.J.8.G.6....................A...........................>..Gd-.;.A..MQ..L.0.H.2.9. . .7.7.7.6.7.4. . . . . . . . ........BO

The -o option lets you change the bootorder:

-o | --bootorder XXXX,YYYY,ZZZZ              
Explicitly set BootOrder (hex).  Any value from 0 to FFFF 
is accepted so long as it corresponds to an existing 
Boot#### variable, and zero padding is not required.

Example:

sudo efibootmgr -o 0
[sudo] password for rinzwind: 
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000
Boot0000* ubuntu
Boot0044* UEFI OS
Boot004E* ubuntu
Boot004F* CD/DVD Drive 

and

 sudo efibootmgr -o 4F
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 004F
Boot0000* ubuntu
Boot0044* UEFI OS
Boot004E* ubuntu
Boot004F* CD/DVD Drive 

1 small issue: not all bios are correctly storing this so if yours faulty too it might reset to the previous; in that case you would need to redo the command every time.

Tagged : / /

Leave a Reply

Your email address will not be published. Required fields are marked *