Page 1 of 1

How to Raid 5 with 5 drives

Posted: Wed Oct 14, 2009 7:44 pm
by carltonb
I have a machine set up that houses 5 drives.

Drive 1 is a 500g, while drives 2,3,4,5 are all 1TB.
I want to use the 500g drive for the program, while 2-5 are for a Raid 5 setup.

Can any one point me in the direction of a post or article on how to set it up.

Thanks
carltonb

Re: How to Raid 5 with 5 drives

Posted: Thu Oct 15, 2009 12:48 am
by moredruid
Well, just install everything as per the instructions on the Amahi site. Leave the disks you want to use as the RAID 5 set untouched.
When the install is finished you can create the RAID array as follows (if you've installed your OS on /dev/sda):
*work as root on a terminal*

Code: Select all

mdadm --create /dev/md1 --level=5 /dev/sd[bcde]
Then save the config to disk:

Code: Select all

mdadm -D -s > /etc/mdadm.conf
Create a volume group with a logical volume on the disk for you data:

Code: Select all

pvcreate /dev/md1 vgcreate vgdata /dev/md1 vgdisplay
Here you will see the output of the volume group, note the "free PE" number and put that number behind the -l option in the lvcreate line:

Code: Select all

Free PE / Size 2305 / 9.00 GB lvcreate -l 2305 -n lvdata vgdata mkfs.ext4 /dev/vgdata/lvdata
I chose the ext4 filesystem, but if you want a different filesystem (ext3, reiserfs, xfs) you can do that if you want, you just need to substitute the mkfs command with the option you want.
Now we need to set it all up so you can actually use it. First we need to temporarily copy everything in /var/hda/files to a different folder:

Code: Select all

mkdir /tmp/tempfiles mv /var/hda/files/* /tmp/tempfiles
Now we test the filesystem:

Code: Select all

mount /dev/vgdata/lvdata /var/hda/files mount
You'll see that the logical volume is mounted on /var/hda/files. You can also type "df -h" and you'll see that /var/hda/files has tons of free space.
Now we move the files back to where they belong:

Code: Select all

mv /tmp/tempfiles/* /var/hda/files
Last part: unmount the filesystem and make sure that the disks are mounted at boot time:

Code: Select all

umount /var/hda/files cp /etc/fstab /etc/fstab.backup echo "/dev/vgdata/lvdata /var/hda/files ext4 defaults 1 2" >> /etc/fstab
Make sure the whitespace is preserved when copying the last line!
Check if the line has been added correctly & mount the filesystem

Code: Select all

cat /etc/fstab mount -a
If you get no errors on the last command (mount) the filesystem is up and will be brought back up at subsequent bootups.

Re: How to Raid 5 with 5 drives

Posted: Thu Oct 15, 2009 8:04 am
by marcel
I do not want to hijack this topic, but i have also a few question about raid, spin down raid arrays, rebuilding raid arrays. You now a lot about Linux moredruid. I will open a new topic for these questions when i have time. :)

Re: How to Raid 5 with 5 drives

Posted: Thu Oct 15, 2009 10:35 am
by moredruid
sure, shoot... :)

it might indeed be interesting to have some kind of reference for setting up RAID.