无需使用 BIOS 设置即可更改硬盘启动顺序

无需使用 BIOS 设置即可更改硬盘启动顺序

抱歉重复提问,但我已经阅读了以下链接:

但以上链接均未解决我的问题。

其实问题是一样的,只是意思不一样。我想更改电脑上的磁盘启动顺序(哪个磁盘将首先启动,其次启动,第三启动。如 CD-ROM -> 硬盘 -> USB 驱动器).我可以使用BIOS 设置,但我想更改磁盘启动顺序使用 Ubuntu

sudo fdisk -l当我在终端上输入时,我得到以下结果。

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)

目前,我有两个磁盘一个内置硬盘 (1 TB) 和第二个外部 USB 驱动器 (14.9 GB)。

Linux下有没有什么命令?

答案1

是的,EFI 有:启动管理器

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

... 显示当前启动顺序。efibootmgr -v(更多详细信息,包括 GUID)列出它们:

BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000
Boot0000* ubuntu    HD(1,GPT,066aad32-119e-407c-af62-64ce08918c66,0x800,0x17800)/File(\EFI\ubuntu\shimx64.efi)
Boot0044* UEFI OS   HD(1,GPT,066aad32-119e-407c-af62-64ce08918c66,0x800,0x17800)/File(\EFI\BOOT\BOOTX64.EFI)
Boot004E* ubuntu    HD(1,GPT,066aad32-119e-407c-af62-64ce08918c66,0x800,0x17800)/File(\EFI\Ubuntu\grubx64.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

-o选项允许您更改启动顺序:

-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.

例子:

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 

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

1 个小问题:并非所有 BIOS 都正确存储了这些信息,因此如果您的 BIOS 也有故障,它可能会重置为之前的状态;在这种情况下,您每次都需要重执行该命令。

相关内容