我刚刚用mdadm创build了一个CentOS 6.3 64位服务器,但是一个灯泡继续运行,我意识到grub只能安装在第一个驱动器上,而第一个驱动器和摩托车上的烟灰缸一样多。
我看了一下,以确认我的怀疑:
grub> find /grub/stage1 find /grub/stage1 (hd0,0)
所以我更新了我的设备映射,如下所示:
(fd0) /dev/fd0 (hd0) /dev/sda (hd1) /dev/sdb
(注意(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
所以我做了一些谷歌search(可惜谷歌刚刚做了一个很好的工作,拿起了100的grub安装示例,这里没有帮助)
find一些线索后我尝试了一下:
# 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
grub现在也安装在/ dev / sdb上,但是如果再看一下,我仍然可以得到:
grub> find /grub/stage1 find /grub/stage1 (hd0,0)
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
SDB
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
和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]
有没有人能够对这种情况有所了解,现在感觉我现在已经有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
/在md0上,由sda2和sdb2组成,swap是md1,即sda3,sdb3 md2是LVM,但是/ boot只在/ sda1上
我想这就是问题了,解决方法是创buildmd4并让它包含sd a 1和sd b 1
也许我的脑海里混杂了一些东西,但我认为grub没有安装在分区上,但驱动器的前几个块,即sda或hd0 / 1
任何澄清和build议表示赞赏。
这应该是你的问题
root (hd1,0) Filesystem type is ext2fs, partition type 0x83
采取以下步骤:
强制磁盘成为一个全新的RAID:
mdadm --zero-superblock /dev/sda1 mdadm --zero-superblock /dev/sdb1
在创build将作为/ boot分区的raid元数据时,使用0.9版本。 Linux无法自动检测更新版本(没有虚拟硬盘)。
mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1 --metadata=0.9
格式使用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
编辑你的bootloader(指示Grub1)
search“默认”行并添加“fallback”选项
vi /boot/grub/menu.lst default 0 fallback 1
再给你的bootloader添加一个条目(在我的例子中,我select了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
请注意,在我的情况下,我的/ md raid上有一个LVM图层。
完成。 这应该足以让你有一个“冗余”的引导程序。
无论你想将这两个驱动器映射到另一个raid1arrays是由你决定的。 这是一个合法的select,因为你可以直接安装grub到md4 ,避免手动pipe理这两个安装的喧嚣。 我已经做到了。
根据我的经验,设备映射文件在很大程度上是不相关的,它的行为(如何读取它)最好是不可预知的,即使不是完全随意的。
来自grub shell的device命令更加可靠。 你可以阅读关于它的帮助信息,但是基本的语法本身是可以说明的:
grub> device (hd0) /dev/md4
之后,在当前正在运行的grub会话中,/ dev / md4将被映射到hd0 ,忽略设备映射文件。 从这里开始,像往常一样使用root (hd0)和setup (hd0,x) 。 亨利S解释了安装到分区的原因。
AFAIK,除了写入驱动器(MBR)的前512个字节的“启动代码”(stage1)以外,唯一的区别是该阶段应该查找菜单的分区数。
这可能会搞砸了。 在POST之后会有一个提示符而不是菜单,但是grub提供了用于从不同的分区(文件)中初始化该菜单的命令,而不是在安装时指定的那个分区(文件)。 它通常在没有干预的情况下工作,因为在BIOS中的“第一启动驱动器”将被检测为“hd0”。