Categories
Hardware Linux Ubuntu

Ubuntu Server – Creating an expandable Raid5 Array starting with 2 disks

Again, I’m using VirtualBox to test this, I have a single OS drive with Ubuntu Server (intrepid) installed. I’ve added two 2gb virtual disk to it, which will be the starting point of the Raid5.  Most places on the net say you need at least 3 disks to run raid 5, but let’s see what happens.

Lets create the raid:

mdadm --create /dev/md0 --level=5 --raid-devices=2 /dev/sdb /dev/sdc

The raid gets created! and we can monitor it with

cat /proc/mdstat

When it has finished intitialising, create a file system on the raid array (ext3):

mke2fs -j /dev/md0

create a mount point (/raid) and mount it

mkdir /raid
mount /dev/md0 /raid

df then reports it as having 2Gb free.  Both my VM drives sdb and sdc are 2Gb, so the assumption is it is simply mirroring the data in 2 drive mode.  This is exactly what we want, as when I get a new drive later on, I want to add it to the raid and see an increase in disk space.  So lets test that, shutdown my machine and add a new drive.

Add the drive to the array

mdadm --manage --add /dev/md0 /dev/sdd

now when I run cat /proc/mdstat it says there are 3 drives in the arras but sdd is marked (S)

Lets now grow the array

mdadm --grow --raid-disk=3 /dev/md0

Watch the progress with cat /proc/mdstat and when complete we can mount it. (adding the 2Gb took about 5 mniutes! eeek! to grow the array).

After completion /proc/mdstat now reports 4gb available, but the file system on the raid still thinks it’s 2gb.

So let’s resize it:

e2fsck -f /dev/md0
resize2fs /dev/md0

Re mount /dev/md0 and df now reports 4Gb.

Success.

2 replies on “Ubuntu Server – Creating an expandable Raid5 Array starting with 2 disks”

Hi matt,

I too have been looking at the Tranquil barebones server. I notice you are using mdadm in your testing, do you intend to stick with software RAID or try to get the SiliconImage hardware raid in the server working? I am following your progress with interest, when is your server due?

Cheers and thanks

Yes,
I decided on software raid as:
1) the code base is open, so it should be more stable than the propitiatory firmware on the card.
2) afaik its a fake raid (i.e. still use the cpu rather than an onboard cpu)
3) if the raid controller died, i’d have to source the same controller to read the data on the drives.
4) If the hardware (not drives) failed I can take the drives and stick them in a completely different ubuntu based machine and still read them.

Hopefully, I should be able to order it at the start of next month.

Comments are closed.