My First Raid-5 Array with Linux Software Raid.
After looking at all the junk I had managed to accumulate over a the last few years, I decided that it was time to invest in some kind of failsafe if my hard drives ever died. Raid seemed an obvious solution and I knew that linux had software raid support. Suprisingly enough, this was incredibly easy to implement and within a couple of hours (Most of that time spent waiting for things to finish, like the building array bit...) I had a working raid 5 array!
The first step was to format all of the drives using the Linux raid autodetect partition type with fdisk. This was 1 command followed by some navigation of the menu based fdisk. "/sbin/fdisk /dev/sdx", where x is the number of the drive you are jibbling with.
Next, once the drives were formatted correctly, it was time to create the array. Again, a single command was issued and the system went away and did its thing..."/sbin/mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1"
After a fairly long time, I had a working array. I checked on its status using "/sbin/mdadm --detail /dev/md0".
I just needed to put the filesystem on top of the array..."mke2fs -j /dev/md0". That took a little while, but not as long as the building array stuff.
Finally, added the array to fstab so that it would be mounted every time I booted. (Edited /etc/fstab and added a line: "/dev/md0 /mnt/storage/ ext3 defaults 0 0").
If you want to grow the array later, back everything up and then tap in the following commands:
- fdisk /dev/sdx
- Add a partition with type "fd"
- mdadm --add /dev/md0 /dev/sdx1
- mdadm --grow /dev/md0 --raid-devices=5
These can be done with the array online, although access will be quite slow. You will need to unmount the array before continuing...
- fsck.ext3 /dev/md0 (-f may be needed if fsck decides not to fsck)
- resize2fs /dev/md0
Now remount the array and enjoy the extra space!