Create a Linux software RAID array

Posted February 12, 2009 by Al Banks in Linux

This recipe is a spin-off from my blog entry on building an inexpensive storage server, if you want more commentary, see my blog.

Note, I’ve done this on an Ubuntu system – other distributions may be slightly different.

First thing, the mdadm utility is needed. sudo apt-get install mdadm will grab this for you.

Next, we’ll need some disk partitions. These can be on the same physical disk (mdadm may gripe about this), good for testing, but for “real” data, use partitions on separate physical disks.

In this example, I have /dev/sda3, /dev/sdb3, and /dev/sdc4, all are are 1175GB.

Now, let’s build…

sudo mdadm --create /dev/md0 --level=RAID5 --raid-devices=2 /dev/sda3 /dev/sdb3 /dev/sdb4

There are other levels which may be more appropriate to your situation.

Give this a little bit of time to run, you can check progress with sudo mdadm -D /dev/md0 or cat /proc/mdstatThese will give you a good idea of the time remaining in the array construction.

Let mdadm run its course for a while, then you can go ahead and format the drive. I did this before the build was complete, but you can wait if you want.

I chose jfs, but there are other filesystems that may be appropriate for your needs. mkfs.jfs /dev/md0

Once the filesystem is done, mount the device to use it. I created a directory, /mnt/raid, and mounted the device there:mount /dev/md0 /mnt/raid

If desired, an entry can be created in fstab to make this easier.

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply