linux重做raid出现grub,用grub引导software raid1上的Linux

使用soft raid的一个好处就是和硬件无关。当硬件完蛋的时候你只能找一样的硬件来读数据,而软件的话完全就挂在

一个新的LINUX系统上就OK。如果不是RAID5,那么实际上作RAID1的话性能应该不用太担心,毕竟有8个逻辑CPU…

可以做这么一个方案:

系统主板上两个同样的硬盘,安装redhat enterprise linux 4.2,安装的时候将两个硬盘的分区改为一致,并都设置为

SOFTWARE RAID1。然后继续安装。

那么安装完毕后,完全可能出现系统不能启动,或者grub可以进行第一步启动,但是找不到/分区或者核心的问题,那么

就要采取如下的方法来解决这个问题了,原文出处:

http://www.redhat.com.cn/kbase/6046.php

现象:

如果你在软件RAID上安装了一个操作系统,系统会无法引导或者只能从其中的一个硬盘引导。而不是所需要的硬盘冗余,即可以从任意一个硬盘引导。

你最好多少能够熟悉一些硬盘寻址和分区的知识和一些基本的Linux引导信息。还需要能够熟练的使用vi来编辑一些配置文件。

解决方法:

因为存储设备的差异非常大,安装程序(Anaconda)可能不能正确设置每一个引导驱动器的主引导记录(MBR)。MBR使用硬盘前512个字节的一部分,位于分区表之后。它包含引导加载Linux所需的自举程序的代码。

如果磁盘没有包含GRUB,系统将不能从第二个硬盘启动,第二种可能是GRUB被安装到了另一个磁盘的MBR上去了,第三种可能,如果机器没有正确 的关闭,则MBR中的GRUB信息可能会在同步的时候被空字节所代替。确认是否以上的可能性,可以手工的重新安装GRUB.可以在一个正在运行的机器或者 启动到救援模式下,

如果在救援模式下,使用chroot改变当前root到/mnt/sysimage,切换到GRUB目录/boot/grub. 编辑文件device.map. 设置要安装GRUB的磁盘和设备。如果你的软件RAID是基于两个IDE硬盘hda和hdc,这个文件可以设置如下:

# this device map was generated by anaconda

(fd0) /dev/fd0

(hd0) /dev/hda

(hd1) /dev/hdc

请注意,上文中的设备指的是整个设备(hdx)而非一个分区。 假设你的/boot分区是硬盘上的第一个分区,GRUB会把他们认成(hd0,0)和(hd1,0)。确认grub.conf中的设置是否和上述一致。同 样你需要创建一个备份的启动项去启动这个系统:如下例:

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE: You have a /boot partition. This means that

# all kernel and initrd paths are relative to /boot/, eg.

# root (hd0,0)

# kernel /vmlinuz-version ro root=LABEL=/

# initrd /initrd-version.img

#boot=/dev/hda1

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

#Boot from /boot partition, /dev/hda1

title Red Hat Enterprise Linux Disk A (version)

root (hd0,0)

kernel /vmlinuz-version ro root=LABEL=/

initrd /initrd-version.img

#Boot from /boot partition, /dev/hdc1

title Red Hat Enterprise Linux Disk C (version)

root (hd1,0)

kernel /vmlinuz-version ro root=LABEL=/

initrd /initrd-version.img

最后,使用grub命令,并在grub SHELL中手动的安装GRUB到每个设备的MBR.你可以使用GRUBroot命令和setup命令来实现上述操作。现把包含/boot的分区传递给 root命令。然后使用setup命令把GRUB MBR的代码写入需要引导的设备。操作步骤如下:

# /sbin/grub

GNU GRUB version 0.xx (640K lower / xxxxK upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB

lists possible command completions. Anywhere else TAB lists the possible

completions of a device/filename.]

grub> root (hd1,0)

Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd1)

Checking if "/boot/grub/stage1" exists... no

Checking if "/grub/stage1" exists... yes

Checking if "/grub/stage2" exists... yes

Checking if "/grub/e2fs_stage1_5" exists... yes

Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.

succeeded

Running "install /grub/stage1 (hd0) (hd0)1 15 p (hd0,0)/grub/stage2 /grub/grub

.conf"... succeeded

Done.

grub> root (hd0,0)

Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd0)

Checking if "/boot/grub/stage1" exists... no

Checking if "/grub/stage1" exists... yes

Checking if "/grub/stage2" exists... yes

Checking if "/grub/e2fs_stage1_5" exists... yes

Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.

succeeded

Running "install /grub/stage1 (hd0) (hd0)1 15 p (hd0,0)/grub/stage2 /grub/grub

.conf"... succeeded

Done.

grub> quit

在上述例子中,在两块硬盘上都已经安装成功,我们可以返回安装程序或者是正常运行的系统。重新启动系统确认系统是否能够引导。还需要模拟SoftRAID中的一个硬盘失败的情况下,系统可以从另一快硬盘引导而且数据可以恢复。

Leave a Comment

要发表评论,您必须先登录。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值