Initrd for root-raid-boot
Now we can prepare our system for raid-boot. First edit "/etc/mkinitrd/mkinitrd.conf" and change the line "ROOT=probe" with "ROOT=/dev/md/1". Then add all neccessary modules for root-raid mount in "/etc/mkinitrd/modules":
fcmaster01:~# cat /etc/mkinitrd/modules
# /etc/mkinitrd/modules: Kernel modules to load for initrd.
#
# This file should contain the names of kernel modules and their arguments
# (if any) that are needed to mount the root file system, one per line.
# Comments begin with a `#', and everything on the line after them are ignored.
#
# You must run mkinitrd(8) to effect this change.
#
md
raid1
ext3
fcmaster01:~#
Then we can create our initrd:
fcmaster01:~# mkinitrd -o /boot/initrd.img-2.4.18-1-k7.raid /lib/modules/2.4.18-1-k7/
/usr/sbin/mkinitrd: RAID support requires raidtools2
fcmaster01:~#
Oh, wat's this ? The stable version (0.1.32woody.3) is not working with mdadm. It need raidtools 2. But raidtools2 does not work correctly (believe me, the system hangs at boot if one particualary disk in the root raid is not physical available).
So we have to install a higher version of initrd-tools. I think since 0.1.49 it works fine. In my case i plan to install a kernel 2.4.24 later so i also need to install a higher version.
So i downloaded initrd-tools-0.1.54, module-init-tools-3.0-pre5 and modutils-2.4.15 and installed ist manuelly (if it is OK for you you can also put an entry in your "/etc/apt/sources.list" - see i.e.
Debian Backports).
For manual installation you also need package stat from stable (note the order):
fcmaster01:~# apt-get install stat
...
fcmaster01:~# dpkg -i modutils_2.4.26-0.backports.org.1_i386.deb
...
fcmaster01:~# dpkg -i module-init-tools_3.0-pre5-0.backports.org.1_i386.deb
...
fcmaster01:~# dpkg -i initrd-tools_0.1.54_all.deb
...
Note
Don't let dpkg overwrite your "/etc/mkinitrd/mkinitrd.conf" file !
Now we are ready to create our initrd image:
fcmaster01:~# mkinitrd -o /boot/initrd.img-2.4.18-1-k7.raid /lib/modules/2.4.18-1-k7/
Of course we can look in it o see what it does:
fcmaster01:~# mount -o loop -t cramfs /boot/initrd.img-2.4.18-1-k7.raid /mnt
fcmaster01:~# cat /mnt/script
mdadm -A /devfs/md/1 -R -u 8dfdd70c:ba733329:6f499349:fb2c1b43 /dev/ide/host0/bus0/target0/lun0/part1
fcmaster01:~# umount /mnt/
If mkinitrd see's the "root=/dev/
Important
md/1" line in "/etc/mkinitrd/mkinitrd.conf" it calls "mdadm -D /dev/md/1" and uses the output for the startup line in the initrd.
Note
Don't forget that the raid will only be startet with ONE partition (the raid is currently degraded) so we need a second call of mkinitrd after the raid ist complete the first time (see later)
If you want to test this you can take the mdadm-line from the initrd (you have to replace "/devfs/md/1" with "/dev/md/1"):
fcmaster01:~# mdadm -S /dev/md/1
fcmaster01:~# mdadm -A /dev/md/1 -R -u 8dfdd70c:ba733329:6f499349:fb2c1b43 /dev/ide/host0/bus0/target0/lun0/part1
mdadm: /dev/md/1 has been started with 1 drive.
fcmaster01:~# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md1 : active raid1 ide/host0/bus0/target0/lun0/part1[0]
3903680 blocks [2/1] [U_]
md5 : active raid1 ide/host0/bus0/target0/lun0/part5[0]
979840 blocks [2/1] [U_]
unused devices: >none<
fcmaster01:~#
So now all works fine :)