我不会涵盖在 Linux 上设置 raid0/1/5 的基本原理,这些内容在其他地方有详细介绍。 我将要解决的问题是设置根目录 raid 并使其可以通过标准 LILO 引导。 LILO 源代码(不是 man 手册)和 raidtools-0.90 附带的文档分别涵盖了引导和引导参数的细节以及通用的 raid 设置。
这里涵盖两种情况。 设置可引导的根目录 raid 以及将现有非 raid 系统转换为可引导的根目录 raid 而不丢失数据。
为了使引导信息冗余且易于维护,请设置一个小的 RAID1 并将其挂载到系统磁盘的 /boot 目录。 LILO 不知道设备 0x9??,并且在启动时无法找到信息,因为那时 raid 子系统未激活。 作为一种简单的解决方法,您可以将驱动器的一个或多个几何信息传递给 LILO,这样,即使内核位于 RAID1 分区上,LILO 也可以确定加载内核所需信息的位置。 这是因为 RAID1 分区与标准分区相同,只是在末尾写入了 raid 超级块。 引导 raid 集应该落在磁盘驱动器的前 1024 MB 范围内。 理论上,raid 分区的起始位置可以落在 1024 MB 范围内的任何位置,但实际上,除非引导 raid 从该集合的第一个块开始,否则我无法使其工作。 这可能是因为我做了一些愚蠢的事情,但这在当时不值得跟进。 从那时起,我只是将所有系统的引导 raid 集设置为第一个分区。 我有根目录 raid 系统配置,其中可引导的 RAID1 挂载在 /boot 上,根目录 raid 集如下:RAID1、RAID5、RAID10 和 RAID1-10(1 个镜像 + 1 个 raid0 集)。 最后一个具有非常特殊的 lilo 文件对,因为没有磁盘几何信息是相同的,但是,对于初始引导过程,原理是相同的。 RAID10 和 RAID1-10 根目录挂载需要在引导过程发生后使用 initrd 来挂载根目录。 有关所有这些示例系统的配置文件,请参见附录。
一个传统的精简 LILO 配置文件如下所示
# lilo.conf - assumes drive less than 1024 boot = /dev/hda delay = 40 # extra, but nice vga = normal # not normally needed image = /bzImage root = /dev/hda1 read-only label = Linux
一个 raid LILO 配置文件对将如下所示
# lilo.conf.hda - primary ide master disk=/dev/md0 bios=0x80 sectors=63 heads=16 cylinders=39770 partition=/dev/md1 start=63 boot=/dev/hda map=/boot/map install=/boot/boot.b image=/boot/bzImage root=/dev/md0 read-only label=LinuxRaid # --------------------- # lilo.conf.hdc - secondary ide master disk=/dev/md0 bios=0x80 # see note below sectors=63 heads=16 cylinders=39770 partition=/dev/md1 start=63 boot=/dev/hdc # this is the other disk map=/boot/map install=/boot/boot.b image=/boot/bzImage root=/dev/md0 read-only label=LinuxRaid
# BIOS=行 -- 如果您的 bios 足够智能(大多数不是)来检测到第一个磁盘丢失或故障,并将自动从第二个磁盘启动,那么 bios=81 将是此处的适当条目。 这在 SCSI bios 中比 IDE bios 更常见。 我只是计划重新定位驱动器,以便在主引导驱动器发生故障时,它将替换死驱动器 C:
驱动器的几何信息可以从 fdisk 命令获得
fdisk -ul (little L) fdisk -ul /dev/hda Disk /dev/hda: 16 heads, 63 sectors, 39770 cylinders Units = sectors of 1 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 63 33263 16600+ fd Linux raid autodetect /dev/hda2 33264 443519 205128 82 Linux swap /dev/hda3 443520 40088159 19822320 fd Linux raid autodetect * note the listing of the START of each partition
上面 raid lilo.conf 文件,对每个条目进行了详细注释。
# lilo.conf.hda - primary ide master # the location of the /boot directory that will be # designated below as containing the kernel, map, etc... # note that this is NOT the actual partition containing # the boot image and info, but rather the device # that logically contains this directory. # in this example, /dev/md1 is mounted on /dev/md0/boot disk=/dev/md0 # tell LILO which bios device to use for boot, i.e. C: drive bios=0x80 # tell LILO the geometry of the device # this is usually but not always the "logical" # geometry. Check the /proc file system or watch # the boot messages when the kernel probes for the drive # sectors=63 heads=16 cylinders=39770 # this is a dummy entry to make LILO happy so it # will recognize the raid set 0x9?? and then find # the START of the boot sector. To really see # what this was for, read the documentation # that comes with the LILO source distribution. # This parameter "must" be different than the # disk= entry above. It can be any other mdx # device, used or unused and need not be the one # that contains the /boot information # partition=/dev/md1 # the first sector of the partition containing /boot information start=63 # the real device that LILO will write the boot information to boot=/dev/hda # logically where LILO will put the boot information map=/boot/map install=/boot/boot.b # logically where lilo will find the kernel image image=/boot/bzImage # standard stuff after this # root may be a raid1/4/5 device root=/dev/md0 read-only label=LinuxRaid