Root file system on software RAID-0 THE EASY WAY

Author: David Flater,
Last modified: Sun Jun 2 10:52:56 EDT 2019


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):

  • Autodetect RAID arrays during kernel boot (CONFIG_MD_AUTODETECT)
  • Linear (append) mode (CONFIG_MD_LINEAR)
  • RAID-0 (striping) mode (CONFIG_MD_RAID0)
  • [... other RAID modes ...]
  These are not the same as the RAID option under "Device mapper support."

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,, 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.

  1. Replaced the Slackware kernel package with my own build of mainline kernel 3.7.9 in which most things are built in.  Only certain things (like ALSA) really need to be modules.
  2. At the root prompt after booting from the CD, partitioned the two hard disks using fdisk.
    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
  3. Still at the root prompt, created the RAID array, telling mdadm to use the old 0.90 superblock format:
    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.

  4. Started Slackware setup.
  5. Specified /dev/md0 as the root file system and formatted it.
  6. Formatted /dev/sda2 and mounted it on /boot.
  7. Ran through the remaining Slackware install process as usual, allowing it to drop the kernel into /boot and choosing /dev/md0 as the root during LILO installation.  (One does not need to say anything about /dev/sda2 in lilo.conf.)
  8. Exit setup and reboot.  It boots.  Done!


  1. The RAID used here was Linux's own software RAID, which always works.  It did not involve the BIOS of a modern "fakeraid" motherboard or anything else.
  2. RAID-1 (mirrored not striped) does not necessitate a separate boot partition.  LILO can boot the kernel directly from any device in the array.  RAID-0 is a challenge because a kernel stored within the RAID array would get split across the multiple devices, and LILO needs it in one piece to boot it.
  3. /dev/mdN is used for a non-partitionable array.  A partitionable array would use /dev/md_dN or /dev/md/dN instead.  See the DEVICE NAMES section at the bottom of the mdadm man page.
  4. The kernel RAID autodetect feature has been called "deprecated" for a long time, but if it suffices for the task, it's still the easiest way.

Log messages

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.