Up one level
Setting up a simple Software RAID volume in Linux
Spencer Stirling

I recently had the displeasure of setting up a Software RAID volume using my new SATA 250GB drives. The following instructions work both for RAID level 5 and RAID level 0, although I found that level 5 dragged my system down to a screeching halt. This configuration is for simple installations - meaning I am not booting off of RAID.

After setting up a RAID 0 (striped volume) using two 250GB drives I tested the performance, and frankly I wasn't impressed. The claim is that, by using the resources of two drives in parallel, you should be able to obtain nearly double the bandwidth. I found that this was certainly not the case, although perhaps my computer is too slow for a fair test. In fact, I found that the performance was nearly identical to just a single drive by itself. Please see the above article for more discussion about this.

On a Debian system the relevant RAID package is called "mdadm" (which contains the relevant mdadm utility to set up and manage RAID volumes). You will need to make sure that RAID is compiled into your kernel - see elsewhere for instructions about that.

After installing the package "mdadm" I tried to create a RAID volumes using two SATA drives (each partitioned already), namely /dev/sda1 and /dev/sda2. Following the instructions for the use of mdadm I encountered several hours worth of difficulties. Nearly every piece of this was due to the fact that I am using "udev" which interferes with mdadm's ability to glue these different devices together into one big device. Also, the syntax was a bit strange for the command line (but enough about that).

Here are step by step instructions that worked in kernel 2.6.11 using udev. First, I created a new "RAID device" /dev/md0 by issuing the commands

mknod -m 0660 /dev/md0 b 9 0
chgrp disk /dev/md0

The second line isn't really necessary, but since every other disk on my system is owned by the "disk" group I thought that I'd put it in there. The /dev/md0 device will need to be manually created EVERY time you reboot. Because of this I put these commands into /etc/init.d/bootmisc.sh (see later for all of the relevant commands).

Now it's time to actually glue /dev/sda1 and /dev/sdb1 together into /dev/md0. For this I issued:

mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sd[ab]1

This only needs to be run once - just to CREATE the RAID array. Notice that I specified 2 "devices", and notice the handy syntax at the end to specify these two devices (partitions) in one blow. I actually had a bit of a problem listing these devices separately (comma-separated, white-space separated, whatever), but I think that there might be a small bug in the version of mdadm that I am using (shrug).

Now the device /dev/md0 is your new RAID device. It can be formatted and used like normal (i.e. mkreiserfs /dev/md0). There IS one caveat to this, and that is that you will NOT be able to mount /dev/md0 automatically in /etc/fstab since the device /dev/md0 has to be created manually in the startup scripts (run long after /etc/fstab stuff is mounted). This might be different using other methods, but not THIS method.

Now my RAID volume needs to be mounted as my /home directory every time I reboot, hence I placed all of the following lines in /etc/init.d/bootmisc.sh:

mknod -m 0660 /dev/md0 b 9 0
chgrp disk /dev/md0
mdadm --assemble /dev/md0 /dev/sd[ab]1
mount -t reiserfs -o rw,noatime /dev/md0 /home

That's all that I did. The manual "mknod" stuff was really the key to get this all to work. Before that I was receiving all kinds of errors, namely

mdadm: error opening /dev/md0: No such file or directory


mdadm: You haven't given enough devices (real or missing) to create this array

These were very annoying!!!

This page has been visited   times since August 12, 2005