about:benjie

Random learnings and other thoughts from an unashamed geek

More Partitioning - RAID6 This Time!

| Comments

RAID 6 with fives disks (disk 0, 1, 2, 3, and 4) and each group of blocks (orange, yellow, green, and blue) have two distributed parity blocks that are distributed across the five disks

I told you about moving my data over to a RAID1+0 and RAID5 system in this previous post, but, as expected, I never got round to finishing it. Until now, that is…

I went to London on business for a few days, and came back to find MythTV had stopped working. The disk was full, so it had given up, and wouldn’t even let me get in to view the recordings - so I couldn’t even delete some to get it working again! (I wonder why Auto-Expire wasn’t working.) Anyway, this spurred me on to finally finish partitioning/setting up my drives. The process was quite simple, really. The following steps generally assume you are root already (sudo su) because I am a “bad” sysadmin and don’t believe in all this constant sudo malarchy. Following my instructions is, as always, at your own risk. I highly recommend that you read the relevant documentation before proceeding (such as this).

  1. Reboot into Ubuntu “Ubuntu (Linux distribution)”) LiveCD, don’t forget to upgrade the software on the LiveCD to prevent any issues!
  2. Disable swapspace (swapoff /dev/sd[abcd]1).
  3. Use cfdisk to finish formatting the drives (remembering to change partition types to the hexadecimal “fd” - Linux RAID Autodetect). Be careful NOT to modify ANY of the details of the partitions you are already using for data or you will probably lose data!
  4. Reboot back into your real system (not LiveCD - minimizes downtime).
  5. Optional: add hot spares to current RAID5 devices (mdadm /dev/md1 -a /dev/sdf5).
  6. Create the new RAID6 devices (mdadm -C /dev/md3 -l6 -n6 /dev/sd[abcdef]7).
  7. Optional: wait for the devices to finish resyncing (watch cat /proc/mdstat).
  8. Turn the new RAID devices into LVM “Logical Volume Manager (Linux)”) physical volumes (pvcreate /dev/md3).
  9. Stop any services that depend on /data (/etc/init.d/mythtv-backend stop; /etc/init.d/mpd stop).
  10. Unmount the data drive (umount /data).
  11. Add the new physical volumes to the current LVM volume group, “raid5” (vgextend raid5 /dev/md3).
  12. Expand the logical volume to the full size of the volume group (use pvdisplay to find out the size [411.05GB], and then run lvextend -L+411.05G /dev/raid5/data).
  13. Expand the filesystem [ext3] to the full size of the logical volume (e2fsck -f /dev/raid5/data; resize2fs /dev/raid5/data) - running e2fsck on a 600GB drive does take a while… Took about 30 minutes for me with little else running.
  14. Remount the data drive (mount /data).
  15. Restart the services you stopped eariler (/etc/init.d/mythtv-backend start; /etc/init.d/mpd start).
  16. Remember to update (I prefer to re-create) your initramfs and update grub (update-initramfs -k all -c; update-grub)
  17. All done!

I chose RAID6 over 6 disks over RAID5 over 5 disk with one hot spare because it has better redundancy and similar performance. It was added to the kernel at the end of 2003 so I think it should be fairly stable by now.

This process was not too complicated, and all of this can be done with very little downtime (if you are clever/daring, you can even re-partition without rebooting, but that was too risky for me!). You can even do the LVM stuff without taking /data offline! I wouldn’t advise it though.

If this post helps you, please let me know in the comments.

Comments