I recently migrated my network storage server, running Ubuntu Linux incidentally, to a software RAID 5 configuration. RAID level 5 requires at least 3 harddrives; giving you in total N-1 storage, where N is the number of disks in the array. For my deployment, I used 3 120GB drives (mixing IDE and SATA, Linux is indifferent here) giving me effectively 240GB. The missing 120GB is the parity information that allows transparent data recovery when 1 disk in the array fails. I’ve glossed over a lot of the details regarding RAID 5 but a quick google should fill in the blanks if need be.

Here is how I accomplished this under Ubuntu Dapper.

  1. Install mdadm using apt-get, or your favorite package manager. mdadm is the tool used to administer Linux md device arrays (software RAID).
  2. Partition your drives as appropriate using cfdisk /dev/hd<?>. Ensure that all partitions are of equal size and the partition type is set to Linux raid autodetect.
  3. Using mdadm create your RAID-5 device:
    • mdadm --create /dev/md0 --chunk=64 --level=raid5 --raid-devices=3 /dev/hdc1 /dev/hde1 /dev/sda1; substituting for your own /dev/ devices.
  4. Good Good.
    • # cat /proc/mdstat
      Personalities : [raid5]
      md0 : active raid5 sda1[0] hdc1[1] hde1[2]
      234371968 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
  5. Format your newly created /dev/md0 device.
    • mkfs.ext3 /dev/md0
  6. Create a mount point for your RAID-5 array and add it to /etc/fstab so it is mounted automagically on the next reboot.
    • /dev/md0 /storage ext3 defaults 0 1
  7. Getting detailed info about your array.
    • # mdadm --detail /dev/md0
      /dev/md0:
      Version : 00.90.03
      Creation Time : Sat Apr 1 14:01:39 2006
      Raid Level : raid5
      Array Size : 234371968 (223.51 GiB 240.00 GB)
      Device Size : 117185984 (111.76 GiB 120.00 GB)
      Raid Devices : 3
      Total Devices : 3
      Preferred Minor : 0
      Persistence : Superblock is persistentUpdate Time : Tue Apr 18 07:39:21 2006
      State : clean
      Active Devices : 3
      Working Devices : 3
      Failed Devices : 0
      Spare Devices : 0Layout : left-symmetric
      Chunk Size : 64K

      UUID : 51dec40b:2d6fd4cc:a9e0addc:fe5303d4
      Events : 0.176640

      Number Major Minor RaidDevice State
      0 8 1 0 active sync /dev/sda1
      1 22 1 1 active sync /dev/hdc1
      2 33 1 2 active sync /dev/hde1

  8. Managing the RAID device.
    • Setting a disk faulty/failed:
      # mdadm --fail /dev/md0 /dev/hdc1
    • Removing a faulty disk from an array:
      # mdadm --remove /dev/md0 /dev/hdc1
    • Clearing any previous raid info on a disk:
      # mdadm --zero-superblock /dev/hdc1
    • Adding a disk to an array:
      # mdadm --add /dev/md0 /dev/hdc1

RAID can be an intimadating piece of technology but it’s benefits are plainly obvious. Hopefully this framework howto is enough to ease your fears.