Finished converting my Kubuntu 6.06LTS system to RAID1

Had the hardest time finding a document about converting an existing system in-place. Found one that covered setting up RAID1 from scratch (RAID-1 in My Ubuntu Installation); found another that showed how to convert a single partition on an existing system (Personal Bytes » Software RAID in Ubuntu).

Of course, I had made the classic mistake of not looking at the easily-accessible documentation first. The mdadm utility controls the raid process, and its documentation is at /usr/share/doc/mdadm. It also includes a handy little guide: Convert Root System to Bootable Software RAID1 (Debian) (note: local link). The guide includes instructions for using both LILO and grub bootloaders.

<sigh>

I followed the directions, and despite fat-fingering the second of four partitions (swap), causing me to reboot several times to try to fix the /dev/mdN device ordering, I finally got the system completely up and running. I even followed the testing suggestion and pulled the power for the first RAID device, and the second HD booted flawlessly, and reported the obvious - degraded array.

I had the capital and foresight to copy my drive-to-convert bit-for-bit to an external drive, so I knew that if I had to start from scratch, it would cost me a grand total of two hours restoring the image.

The cool thing about the mdadm convert root system docs? I converted my entire system in-place - I did not have to copy to a third hard drive. The instructions were easy to follow, and contained numerous checkpoints as well as several appendices.

Now, my Kubuntu system boots fine, activity that requires reading as opposed to writing happens noticeably quicker, and if one drive fails, I have a perfect duplicate of it, and can restore very easily.

Some useful commands:

df -h
show the mounted filesystems
dd if=/dev/sdX of=/dev/sdY bs=10M & ddpid=$!
copy bit-for-bit from /dev/sdX to /dev/sdY, using 10MB chunks, which speeds up the transfer considerably. I copied a 400GB disk to another identically-sized disk in under 2 hours.
kill -USR1 $ddpid
show the dd command's status without stopping it

Some useful notes:

  • If you see a /dev/md255 or other raid device, with large numbers and dm-1-type devices, ignore them. They are Enterprise Volume Management System drives, probably there because EVMS read the partially-created array and created its own references to the volumes. They won't cause you any trouble, and will go away once you have all your raid partitions fully assembled and running.
  • The prohibition against using your system while the raid is rebuilding? A good idea, but it will not have any ill effects as long as you use the /dev/mdX device. If you use the raid device while it synchronizes, your system will take longer to rebuild the array, but it will still rebuild. Mine worked just fine. Synchronizing 2 raid partitions of around 180GB took about an hour each (all drives were SATA 1.5GBs).

Written by Andrew Ittner in misc on Thu 22 March 2007. Tags: technology, linux