修复 RAID 上 grub 升级失败的问题

修复 RAID 上 grub 升级失败的问题

我们刚刚将专用服务器从 Debian Lenny (5.0) 升级到 Debian Squeeze (6.0)。在此过程中,grub 升级失败。我(也许很愚蠢)遵循了https://askubuntu.com/a/39697/41567,并且 grub 已成功卸载,现在无法重新安装。错误是:

root@gaia:naught101#  grub-install /dev/sda
/usr/sbin/grub-setup: warn: This msdos-style partition label has no
post-MBR gap; embedding won't be possible!.
/usr/sbin/grub-setup: error: embedding is not possible, but this is
required when the root device is on a RAID array or LVM volume.
root@gaia:naught101#  grub-install --recheck /dev/sda
/usr/sbin/grub-setup: warn: This msdos-style partition label has no
post-MBR gap; embedding won't be possible!.
/usr/sbin/grub-setup: error: embedding is not possible, but this is
required when the root device is on a RAID array or LVM volume.
root@gaia:naught101# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.26-2-amd64
Found initrd image: /boot/initrd.img-2.6.26-2-amd64
Found linux image: /boot/vmlinuz-2.6.26-1-amd64
Found initrd image: /boot/initrd.img-2.6.26-1-amd64
     No volume groups found
done
root@gaia:naught101#

我给 Hetzner.de 的服务器技术支持发了电子邮件,他们说这是软件问题,所以我应该能够解决。但是,系统使用 RAID 设置,我不确定应该如何设置分区(甚至不知道我是否可以适当地更改它们)。分区如下:

root@gaia:naught101# parted -l
Model: ATA SAMSUNG HD403LJ (scsi)
Disk /dev/sda: 400GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
   1      512B    2155MB  2155MB  primary  linux-swap(v1)  raid
   2      2155MB  400GB   398GB   primary  ext3            raid


Model: ATA SAMSUNG HD403LJ (scsi)
Disk /dev/sdb: 400GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
   1      512B    2155MB  2155MB  primary  linux-swap(v1)  raid
   2      2155MB  400GB   398GB   primary  ext3            raid


fModel: Linux Software RAID Array (md)
Disk /dev/md0: 2155MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system     Flags
   1      0.00B  2155MB  2155MB  linux-swap(v1)


Model: Linux Software RAID Array (md)
Disk /dev/md1: 398GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system  Flags
   1      0.00B  398GB  398GB  ext3


root@gaia:naught101# fdisk -l

Disk /dev/sda: 400.1 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00012254

     Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         262     2104514+  fd  Linux raid
autodetect
/dev/sda2             263       48641   388604317+  fd  Linux raid
autodetect

Disk /dev/sdb: 400.1 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e7f04

     Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         262     2104514+  fd  Linux raid
autodetect
/dev/sdb2             263       48641   388604317+  fd  Linux raid
autodetect

Disk /dev/md0: 2154 MB, 2154954752 bytes
2 heads, 4 sectors/track, 526112 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/md1: 397.9 GB, 397930725376 bytes
2 heads, 4 sectors/track, 97151056 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md1 doesn't contain a valid partition table
root@gaia:naught101#

我真的不知道该怎么办。http://ubuntuforums.org/showthread.php?t=1539205建议修改分区标志,但我认为在服务器运行时无法这样做?我目前被困在无法启动的服务器上(幸好它仍然在运行)。有人知道这个问题的解决方案吗?

答案1

我们的解决方案基本上是删除/dev/md0和相应的交换分区(/dev/sda1//dev/sdb1),然后重新添加它们,并在启动时留出 8Mb 的可用空间(1Mb 是建议的最小值,但 Linux 的最新版本使用 2Mb;我们不会错过额外的 6Mb),并在启动时在可用空间中安装 grub,使用grub-install /dev/sda; grub-install /dev/sdb; update-grub

实际上,我们在删除时遇到了问题/dev/md0,因此我们删除了,并在顶部安装了 grub,然后重新启动,但md0缺少(因此没有交换)。如果您有足够的内存,这很好。然后我们重新创建了它,并再次重新启动。所有这些都是在系统内部完成的,而不是从 liveCD(我们在不同的大陆)或救援系统完成的。

对于我们的目的而言,这可能是关于修改 mdadm RAID 阵列的更好的教程之一:http://notes.benv.junerules.com/linux-software-raid-disk-upgrades/

相关内容