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
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
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
Re mount /dev/md0 and df now reports 4Gb.