Author: David Flater, firstname.lastname@example.org
Last modified: Mon Feb 25 21:15:49 EST 2013
There are plenty of how-to guides that explain how to get a striped RAID-0 file system mounted as your root file system in Linux using an initramfs. This web page explains a simpler and easier way that requires no initramfs.
If you boot a kernel with RAID and the other necessary drivers built in (NOT as modules), it will automatically assemble partitions of type fd ("Linux raid autodetect") into a RAID array that you can use as your root fs without the need for an initramfs. As of kernel version 3.7.9, the necessary options for RAID are under Device Drivers → Multiple devices driver support (RAID and LVM) → RAID support (CONFIG_BLK_DEV_MD):
Of course, you will also need to build in other essential drivers like those for your hard drive and motherboard chipset. If that is too difficult to figure out, try Slackware's huge.s prebuilt kernel.
You will also need a small, non-RAID partition that is just big enough to hold the stuff that normally goes in /boot (the kernel, System.map, config, and a few LILO files), because the kernel itself cannot be loaded from the RAID array.
Following is what I did to get this working using a Slackware 14.0-based installation CD.
Disk /dev/sda: 6488 MB, 6488294400 bytes 255 heads, 63 sectors/track, 788 cylinders, total 12672450 sectors Device Boot Start End Blocks Id System /dev/sda1 2048 8421711 4209832 fd Linux raid autodetect /dev/sda2 8423424 8525823 51200 83 Linux /dev/sda3 8525824 8787967 131072 82 Linux swap /dev/sda4 * 8787968 12672449 1942241 c W95 FAT32 (LBA)
Disk /dev/sdb: 4311 MB, 4311982080 bytes 58 heads, 61 sectors/track, 2380 cylinders, total 8421840 sectors Device Boot Start End Blocks Id System /dev/sdb1 2048 8421711 4209832 fd Linux raid autodetect
mdadm -C /dev/md0 -l 0 -e 0.90 -n 2 /dev/sda1 /dev/sdb1
If the partitions are different sizes, one can choose linear RAID (a.k.a. JBOD = Just a Bunch of Disks) instead of RAID-0 at this point by saying –l linear instead of –l 0. (TO DO: Test whether the separate boot partition is still necessary for linear RAID.)
If mdadm prints errors about disks already in use, you can get rid of an existing autodetected array with mdadm –S /dev/md0 and then proceed as above.
After creating the array but before going through the entire Slackware setup, it's wise to reboot and see how (and if) the newly created array is autodetected. Just because it works from the command line when you've explicitly specified the devices doesn't mean that it will be autodetected properly by the kernel.
Linux version 3.7.9-hylafax (root@yellowbeard) (gcc version 4.7.2 (GCC) ) #1 Sun Feb 24 09:25:33 EST 2013 md: linear personality registered for level -1 md: raid0 personality registered for level 0 md: Waiting for all devices to be available before autodetect md: If you don't use raid, use raid=noautodetect md: Autodetecting RAID arrays. md: Scanned 2 and added 2 devices. md: autorun ... md: considering sdb1 ... md: adding sdb1 ... md: adding sda1 ... md: created md0 md: bind
md: bind md: running: md/raid0:md0: md_size is 16838656 sectors. md: RAID0 configuration for md0 - 1 zone md: zone0=[sda1/sdb1] zone-offset= 0KB, device-offset= 0KB, size= 8419328KB md0: detected capacity change from 0 to 8621391872 md: ... autorun DONE. md0: unknown partition table EXT4-fs (md0): mounted filesystem with ordered data mode. Opts: (null) VFS: Mounted root (ext4 filesystem) readonly on device 9:0.