我有几个具有相同基本设置的服务器:主驱动器具有 VFAT /boot/efi、XFS /boot 和 LVM 上的 XFS /;辅助驱动器具有完全相同的内容,每个分区每晚进行 rsync。
我还有一个脚本,可以确保(理论上)设置 grub 和 EFI 等,以便在服务器重新启动时从主驱动器启动。通常这是可行的,但在这台特定的服务器上,它似乎总是更喜欢辅助驱动器,即使我更换驱动器。也就是说:它似乎始终在第二个插槽中启动驱动器(尽管值得注意的是,由于我自己连接了驱动器,所以第二个插槽实际上完全有可能首先在主板上枚举,但我不明白这有什么关系)。
以下是 LVM 的情况:
rlpowell@stodi> sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 stodi_orange_2021_10 lvm2 a-- 930.55g 0
/dev/sdb3 stodi_pink_2020_10 lvm2 a-- 930.55g 0
rlpowell@stodi> sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root stodi_orange_2021_10 -wi-ao---- 930.55g
root stodi_pink_2020_10 -wi-ao---- 930.55g
(在此主机上,橙色目前是主要的,粉色目前是次要的。)
当它启动并运行时我们有:
/dev/mapper/stodi_orange_2021_10-root 931G 686G 245G 74% /
/dev/sda2 483M 256M 228M 53% /boot
/dev/sda1 488M 6.4M 482M 2% /boot/efi
rlpowell@stodi> cat /proc/partitions
major minor #blocks name
8 0 976762584 sda
8 1 499712 sda1
8 2 499712 sda2
8 3 975762119 sda3
11 0 1048575 sr0
253 0 975757312 dm-0
8 16 976762584 sdb
8 17 499712 sdb1
8 18 499712 sdb2
8 19 975762119 sdb3
253 1 975757312 dm-1
EFI 情况如下:
rlpowell@stodi> sudo efibootmgr -v
BootCurrent: 0013
Timeout: 30 seconds
BootOrder: 0001,0015,000C,0000,0013,0002,0003,0004,0005,0006,0007,0008,0009,000A,000B,000C,000D,000E,000F,0010,0011,0012,0013,0014,0016
Boot0000 Startup Menu FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)....ISPH
Boot00000013* Samsung SSD 870 EVO 1TB PciRoot(0x0)/Pci(0x11,0x4)/Sata(0,0,0)N.....YM....R,Y.....ISPH
Boot0001* stodi_orange_2021_10 HD(1,GPT,cb8227c2-dc52-fc4f-bd8f-b46f71104428,0x800,0xf4000)/File(\EFI\fedora\shimx64.efi)
Boot0002 Bios Setup FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0003 3rd Party Option ROM Management FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0004 System Diagnostics FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0005 System Diagnostics FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0006 System Diagnostics FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0007 System Diagnostics FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0008 Boot Menu FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0009 USB: BBS(65535,,0x0)/PciRoot(0x0)/Pci(0x1d,0x0)......ISPH
Boot000A Network Boot FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot000B* Samsung SSD 870 EVO 1TB BBS(HD,Harddisk1,0x400)/PciRoot(0x0)/Pci(0x11,0x4)......ISPH
Boot000C* IBA GE Slot 00C8 v1550 BBS(Network,Network1,0x0)/PciRoot(0x0)/Pci(0x19,0x0)......ISPH
Boot000D* IBA GE Slot 0500 v1550 BBS(Network,Network1,0x0)/PciRoot(0x0)/Pci(0x1c,0x0)/Pci(0x0,0x0)......ISPH
Boot000E* IBA GE Slot 0500 v1550 BBS(Network,Network1,0x0)/PciRoot(0x0)/Pci(0x1c,0x0)/Pci(0x0,0x0)......ISPH
Boot000F USB: PciRoot(0x0)/Pci(0x1d,0x0)N.....YM....R,Y.....ISPH
Boot0010* hp DVDRW DU8A6SH PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0,0,0)N.....YM....R,Y.....ISPH
Boot0011* hp DVDRW DU8A6SH BBS(CDROM,CDROM1,0x400)/PciRoot(0x0)/Pci(0x1f,0x2)......ISPH
Boot0012 System Information FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0013* Fedora HD(1,GPT,cb8227c2-dc52-fc4f-bd8f-b46f71104428,0x800,0xf4000)/File(\EFI\fedora\shimx64.efi)....ISPH
Boot0014 HP Recovery FvVol(cdbb7b35-6833-4ed6-9ab2-57d2acddf6f0)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0015* stodi_pink_2020_10 HD(1,GPT,3dc251c1-c845-1f4b-9a0b-ebc15792efd6,0x800,0xf4000)/File(\EFI\fedora\shimx64.efi)
Boot0016* Samsung SSD 860 EVO 1TB PciRoot(0x0)/Pci(0x11,0x4)/Sata(1,0,0)N.....YM....R,Y.....ISPH
这是 grub:
rlpowell@stodi> sudo grub2-editenv /boot/grub2/grubenv list
saved_entry=a7afe39309446d92f17c60bc5467f619-5.14.9-200.fc34.x86_64
kernelopts=root=/dev/stodi_orange_2021_10/root ro rd.auto enforcing=0 crashkernel=auto video=DP-1:1280x1024-32@60e
boot_success=1
boot_indeterminate=0
rlpowell@stodi> sudo cat /boot/loader/entries/a7afe39309446d92f17c60bc5467f619-5.14.9-200.fc34.x86_64.conf
title Fedora (5.14.9-200.fc34.x86_64) 34 (Thirty Four)
version 5.14.9-200.fc34.x86_64
linux /vmlinuz-5.14.9-200.fc34.x86_64
initrd /initramfs-5.14.9-200.fc34.x86_64.img
options root=/dev/mapper/stodi_orange_2021_10-root ro rd.auto enforcing=0 crashkernel=auto video=DP-1:1280x1024-32@60e
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
但如果我重新启动,正如我所说,它最终会可靠地在粉红色 LV 上运行(即在辅助驱动器上)。即使我之前从橙色启动时移除了粉红色驱动器,情况也是如此。
我看不出是什么原因导致这样的情况发生。
也许 BIOS 中发生了一些 efibootmgr 无法影响的事情?
编辑:UUID信息:
rlpowell@stodi> sudo blkid
/dev/sda1: SEC_TYPE="msdos" UUID="E6B6-7A41" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="/boot/efi - EFI System Partition" PARTUUID="cb8227c2-dc52-fc4f-bd8f-b46f71104428"
/dev/sda2: UUID="544b6c29-f436-4b2f-ab73-f2cf643638b7" BLOCK_SIZE="512" TYPE="xfs" PARTLABEL="/boot Partition" PARTUUID="fe677923-076f-2c47-bf0d-98b4d7e3e86f"
/dev/sda3: UUID="ur5eed-EJqk-y2op-F1dY-RpUC-SQGW-MCUk48" TYPE="LVM2_member" PARTLABEL="LVM: root on stodi_orange_2021_10" PARTUUID="b4754fd9-f637-2b4c-9fec-3e120521956f"
/dev/mapper/stodi_orange_2021_10-root: UUID="011f7198-26d2-4c34-bc39-85fc45c55422" BLOCK_SIZE="512" TYPE="xfs"
/dev/sdb1: SEC_TYPE="msdos" UUID="6CBC-8CFB" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="/boot/efi - EFI System Partition" PARTUUID="3dc251c1-c845-1f4b-9a0b-ebc15792efd6"
/dev/sdb2: UUID="0719024b-8442-4b64-a279-842a6533b511" BLOCK_SIZE="512" TYPE="xfs" PARTLABEL="/boot Partition" PARTUUID="8b0e313c-37bc-d242-8b23-b4fc6dbaf519"
/dev/sdb3: UUID="82fp7k-I0Th-92EP-gJ0O-MD5A-efK0-YxZ0bP" TYPE="LVM2_member" PARTLABEL="/ Partition" PARTUUID="b64d042d-443e-6445-afbf-0673810b5a2a"
/dev/mapper/stodi_pink_2020_10-root: UUID="ac593057-5586-416c-b141-c8173cdb4d61" BLOCK_SIZE="512" TYPE="xfs"
答案1
似乎有效的是删除每一个在添加自己的条目之前,请先在其中添加“GPT”条目:
for num in $(efibootmgr -v | grep GPT | sed -r 's/^Boot0*([0-9A-F]+).*/\1/')
do
efibootmgr -b $num -B
done