Bac*_*eek 7 linux centos mdadm grub raid1
我刚刚用 mdadm 完成了一个 CentOS 6.3 64 位服务器的设置,但是一个灯泡亮了,我意识到 grub 只会安装在第一个驱动器上,这与摩托车上的烟灰缸一样多。
我看了一眼,证实了我的怀疑:
grub> find /grub/stage1
find /grub/stage1
(hd0,0)
Run Code Online (Sandbox Code Playgroud)
所以我更新了我的设备地图,看起来像:
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
Run Code Online (Sandbox Code Playgroud)
(注意(hd1)条目是我添加的
所以我尝试在 /dev/sdb 上安装 grub
我得到:
grub> root (hd1,0)
root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
setup (hd1)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... no
Error 15t: File not found
Run Code Online (Sandbox Code Playgroud)
所以我做了一些谷歌搜索(可悲的是谷歌刚刚做得很好,并挑选了 100 个在这里没有帮助的 grub 安装示例)
在找到一些线索后,我尝试了:
# grub-install --recheck /dev/sdb
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
# grub-install /dev/sdb
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
Run Code Online (Sandbox Code Playgroud)
哪种建议 grub 现在也安装在 /dev/sdb 上,但是如果我再看一眼,我仍然会得到:
grub> find /grub/stage1
find /grub/stage1
(hd0,0)
Run Code Online (Sandbox Code Playgroud)
2 个驱动器的分离输出:
SDA
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 500MB 500MB ext3 1 boot
2 500MB 81.0GB 80.5GB 2 raid
3 81.0GB 85.0GB 4000MB 3 raid
4 85.0GB 3001GB 2916GB 4 raid
Run Code Online (Sandbox Code Playgroud)
深圳发展银行
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 500MB 500MB ext3 1
2 500MB 81.0GB 80.5GB 2 raid
3 81.0GB 85.0GB 4000MB 3 raid
4 85.0GB 3001GB 2916GB 4 raid
Run Code Online (Sandbox Code Playgroud)
和 mdadm mdstat:
Personalities : [raid1]
md1 : active raid1 sdb3[1] sda3[0]
3905218 blocks super 1.1 [2/2] [UU]
md2 : active raid1 sdb4[1] sda4[0]
2847257598 blocks super 1.1 [2/2] [UU]
md0 : active raid1 sda2[0] sdb2[1]
78612189 blocks super 1.1 [2/2] [UU]
Run Code Online (Sandbox Code Playgroud)
有没有人能够对这种情况有所了解,感觉现在我 99% 都在那里,但遗漏了一些明显的东西。
谢谢。
编辑更新:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md0 74G 18G 53G 25% /
tmpfs 580M 0 580M 0% /dev/shm
/dev/sda1 462M 98M 341M 23% /boot
xenstore 580M 64K 580M 1% /var/lib/xenstored
Run Code Online (Sandbox Code Playgroud)
/ 在 md0 上,它由 sda2 和 sdb2 交换是 md1,即 sda3,sdb3 md2 是 LVM 但是 /boot 仅在 /sda1 上
我想这就是问题所在,解决方案是创建 md4 并让它包含 sd a 1 和 sd b 1
也许我脑子里有点混乱,但我认为 grub 没有安装在分区上,而是驱动器的前几个块,即 sda 或 hd0/1
任何澄清和建议表示赞赏。
小智 4
这应该是你的问题
root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
Run Code Online (Sandbox Code Playgroud)
采取以下步骤:
强制磁盘成为全新的 raid:
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1
Run Code Online (Sandbox Code Playgroud)创建将成为 /boot 分区的 raid 元数据时,请使用版本 0.9。Linux 无法自动检测较新的版本(没有 ramdisk)。
mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1 --metadata=0.9
Run Code Online (Sandbox Code Playgroud)使用 ext2 或 ext3 格式化
发行版首次启动后:
在2个磁盘MBR上安装grub
# grub /dev/sda
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
quit
# grub /dev/sdb
grub> root (hd1,0)
grub> setup (hd1)
grub> quit
quit
Run Code Online (Sandbox Code Playgroud)编辑你的引导加载程序(Grub1 的说明)
搜索“默认”行并添加下面的“后备”选项
vi /boot/grub/menu.lst
default 0
fallback 1
Run Code Online (Sandbox Code Playgroud)向您的引导加载程序添加另一个条目(同样,在我的例子中,我选择了 grub1,因为它不太复杂并且足以满足我的需求),每个条目都指向属于 raid 成员的不同引导分区:
title Debian GNU/Linux, kernel 2.6.32-5-686 (default)
root (hd0,0)
kernel /vmlinuz-2.6.32-5-686 root=/dev/mapper/vg-root ro quiet
initrd /initrd.img-2.6.32-5-686
title Debian GNU/Linux, kernel 2.6.32-5-686 (fallback)
root (hd1,0)
kernel /vmlinuz-2.6.32-5-686 root=/dev/mapper/vg-root ro quiet
initrd /initrd.img-2.6.32-5-686
Run Code Online (Sandbox Code Playgroud)请注意,就我而言,我的 /md raid 上有一个 LVM 层。
完毕。这应该足以让您拥有一个“冗余”引导加载程序。