This is how I set up my Raid5 Array on Ubuntu Server 10.10. It's not really meant as a guide, more so just a reminder for myself to note what steps I took to set up the array. Basically, I just followed the instructions posted by "santhony" at the Ubuntu forums. So thanks to "santhony".
I have 4 x 500GB Hitachi (Deskstar 7K1000.C) hard drives, attached to a Promise FastTrak TX4310 Raid Controller. The OS (Ubuntu 10.10) is installed on a separate 2.5" Western Digital 250GB drive. The Motherboard is an Intel mini-ITX D945GCLF2, with Atom 330 Processors.
To begin with, we need to install some software to help us do the job. mdadm is a Linux utility by Neil Brown that is used to manage software RAID devices. So yes, we are building a software raid.
sudo apt-get update sudo apt-get install --no-install-recommends mdadm
If you leave out the "--no-install-recommends" option and you don't have postfix installed on your sytem, you will be asked to install it. I am not sure why mdadm specifically needs postfix, but it seems be a dependency. When asked how I wanted to configure postfix, I choose "None", since I actually don't want a mail server on my system.
First, we check what hard drives we have and how they have been named. Yes, that's a small "L" behind the fdisk command.
sudo fdisk -l
The results to note: /dev/sdb, /dev/sde, /dev/sdf, /dev/sdg. Now we create the array with mdadm.
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sdb /dev/sde /dev/sdf /dev/sdg --auto=md
The creation of the array runs in the background an will take several hours, depending on the size of the disks and the array you are making. You can watch the status of the array while it's being built with the following command.
watch -n1 'cat /proc/mdstat'
As you can see, it will give you an estimate when it will be finished (in minutes). Mine is apparently going to take 248.9 minutes (+4 hours) to build the remaning 80%.
While the array is building (syncing), you can already go ahead and format the array. No need to wait for it to be finished. We will format it with a tool called mke2fs for an ext3 file system. You can only format ext2 or ext3 with this program. If you want something else, have a look here.
mke2fs -j /dev/md0
To mount the array, we first need to create a directory to mount it in. I chose the following:
mkdir /mnt/raid mount /dev/md0 /mnt/raid
Once the raid has finished building, you can go ahead an add it to your mdadm.conf and /etc/fstab so it will mount automatically on boot-up. So first we need to know what to enter in the mdadm.conf. Enter the following command and note down the line starting with ARRAY
sudo mdadm --detail --scan --verbose
Add the result with your favourite text editor to mdadm.conf and /etc/fstab. Here, a screenshot of the mdadm.conf:
Afte you added the array, as described above reboot and pray that all will be well. In my case it did. So good luck and enjoy.