Friday, September 6, 2013

Setting Up RAID-1 on Linux Mint 15, Made Easy

Having come from the RHEL/CentOS world, it was a bit of a surprise to me when I installed Linux Mint 15, and noticed the lack of a software RAID setup step during the install process. But this can easily be done once installation is complete ("easy," relative to manually running mdadm, anyway).

Here's a handy little tool I found to ease the implementation of software RAID-1: raider (http://raider.sourceforge.net/).

By using this tool, I didn't lose any data or anything... just installed the OS and then ran raider after the fact. It really wasn't too painful (just takes some time and requires pulling cables a couple times). And, don't be put off by the low version number ~ it worked great for me, for this purpose.

My hardware consists of two hard drives, as follows:
(no LVM, no encryption - just plain, pure hardware devices)
/dev/sda  (2TB WD-black - Linux Mint 15 already installed)
/dev/sdb  (2TB WD-black - some previous file system I don't care about anymore)

If you follow the directions (including physically swapping the two hard drives' SATA cables and allowing them to rebuild), you'll get great results... at least I did.

  1. Download and then extract the package (I used version 0.13.2) anywhere (I used my ~/).
  2. CD into the raider directory and install:
    $ sudo ./install.sh
  3. Make sure you have the required packages installed (I only needed mdadm):
    $ sudo apt-get install mdadm parted sfdisk hdparm rsync bc wget
  4. Make sure you have at least one of the following installed (I already had mkinitramfs): dracut, mkinitcpio, mkinitramfs, mkinitrd, or genkernel
  5. Backup your stuff! (duh) ~ I didn't need to resort to it, but you never know.
  6. Reboot into single user mode:
    1. When booting, hold the shift key until you see the GRUB boot screen.
    2. Press "e" to edit the line, and append the word "single" (without quotes) at the end of the line (in my case, after the "ro quiet splash" part)
    3. Press "Ctrl" + "x" to execute the boot (it'll drop you into command line mode)
    4. Log in as root.
  7. Run the following command... raider will use the drive in the first physical slot (almost always sda) as the "source" drive and you will lose whatever is on the second drive (sdb). Be aware that this might take a long time ~ it took around 5 hours with my 2TB drive that had about 500GB of stuff on it.
    # raider -R1 sda sdb
    • Note: If your sdb had stuff on it before (especially RAID), you might get a message about needing to erase it. If you do, just run the command it says to run: raider --erase /dev/sdb
    • Note: If you get the "fatal error" about not being able to format a particular partition (in my case, it was the swap partition of the old disk), then you'll need to first do an fdisk on sdb, and delete all the partitions (just to be safe - you don't care about them anymore, anyway, right?). Be sure to reboot after you write the changes in fdisk. Then run the raider command again.
  8. Once that completes...
    1. Shutdown the machine
    2. Physically swap the two hard drives' data connectors with each other
    3. Boot back into single user mode (repeat step 6 above)
  9. Run the command:
    # raider --run
    • Essentially, we've now simulated a degraded array (sdb isn't complete, but we're booting from it as sda this time), and we're now going to rebuild it. Other than copying the sda's contents to sdb, the added bonus is that we're also testing the array's ability to rebuild here.
    • Note: this will take quite a long time... for my 2TB drives, it took about 8 hours!
  10. Once that completes... (at this point, you should now have two identical drives as members of a functional and working RAID-1 array)
    1. Shutdown the machine
    2. Physically swap back the two hard drives' data connectors with each other (the way they were originally)
    3. Boot back up as you normally do... you're all done!

1 comment: