背景
我正在设置一个带有软件 RAID1 的服务器。这包括镜像的 /boot 分区(映射到 md0)。我的目标是,如果包含操作系统的两个硬盘驱动器(sdc 和 sdd)中的一个发生故障,我仍然能够使用 grub2 进行引导。
问题
我已通过物理移除其中一个硬盘来测试我当前的设置。当我这样做时,我无法启动,因为 grub 正在寻找 md0 分区,而该分区似乎仅在两个驱动器都存在且正常工作时才可用。以下是错误消息:
Volume group "vg_testfs" not found
Cannot process volume group vg_testfs
lvmetad is not active yet, using direct activation during sysinit
Cannot process volume group vg_testfs
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
Reading all physical volumes. This may take a while...
/run/lvm/lvmetad.socket: connect failed: no such file or directory.
我的尝试
在阅读了一些文档之后,我尝试创建以下脚本文件,但在运行 grub-update 后该脚本文件不起作用:
猫/etc/grub.d/11_recovery1
#!/bin/sh -e
echo "Adding recovery 1"
cat << EOF
menuentry "recovery 1 - bootable when 1 disk fails" {
set root=(hd0,1)
linux /boot/vmlinuz root=/dev/sdc1
initrd /boot/initrd.img
}
EOF
潜在解决方案
我想知道是否可以配置 grub,以便在其他驱动器不存在时,使用附加条目引导到单个软件 RAID 驱动器。如果不行,我是否应该从头开始构建系统,而不使用 RAID1 作为 /boot 分区,而是在每个驱动器 /boot 分区上设置单独的 grub 文件?
我以前从未使用过 grub,不知道从哪里开始!任何帮助都将不胜感激。谢谢
更多信息
lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
sdb
sdc
├─sdc1 linux_raid_member testfs:0 4efe8212-0000-0000-0000-000000000001
│ └─md0 ext4 04d5c4d4-0000-0000-0000-000000000002 /boot
├─sdc2
└─sdc5 linux_raid_member testfs:1 7d1b235d-0000-0000-0000-000000000003
└─md1 crypto_LUKS 41e69905-0000-0000-0000-000000000004
└─md1_crypt LVM2_member 7wHoCZ-0000-0000-0000-00000000000005
├─vg_testfs-lv_swap swap 8112ce83-0000-0000-0000-000000000006 [SWAP]
└─vg_testfs-lv_root ext4 bbe5d21b-0000-0000-0000-000000000007 /
sdd
├─sdd1 linux_raid_member testfs:0 4efe8212-0000-0000-0000-000000000001
│ └─md0 ext4 04d5c4d4-0000-0000-0000-000000000002 /boot
├─sdd2
└─sdd5 linux_raid_member testfs:1 7d1b235d-0000-0000-0000-000000000003
└─md1 crypto_LUKS 41e69905-0000-0000-0000-000000000004
└─md1_crypt LVM2_member 7wHoCZ-0000-0000-0000-00000000000005
├─vg_testfs-lv_swap swap 8112ce83-0000-0000-0000-000000000006 [SWAP]
└─vg_testfs-lv_root ext4 bbe5d21b-0000-0000-0000-000000000007 /
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 / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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 /dev/sdc: 111.8 GiB, 120040980480 bytes, 234455040 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: 0x3c424eec
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 976895 974848 476M fd Linux RAID autodetect
/dev/sdc2 978942 234452991 233474050 111.3G 5 Extended
/dev/sdc5 978944 234452991 233474048 111.3G fd Linux RAID autodetect
Disk /dev/sdd: 111.8 GiB, 120040980480 bytes, 234455040 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: 0x33a774c6
Device Boot Start End Sectors Size Id Type
/dev/sdd1 * 2048 976895 974848 476M fd Linux RAID autodetect
/dev/sdd2 978942 234452991 233474050 111.3G 5 Extended
/dev/sdd5 978944 234452991 233474048 111.3G fd Linux RAID autodetect
Disk /dev/md0: 475.7 MiB, 498794496 bytes, 974208 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 /dev/md1: 111.3 GiB, 119471603712 bytes, 233342976 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 /dev/mapper/md1_crypt: 111.3 GiB, 119469506560 bytes, 233338880 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 /dev/mapper/vg_testfs-lv_swap: 11.2 GiB, 11999903744 bytes, 23437312 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 /dev/mapper/vg_testfs-lv_root: 100.1 GiB, 107466457088 bytes, 209895424 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