Using LVM to migrate filesystems to a RAID device

Introduction

I administer a CentOS 4 server for a small company. The system was originally set up using multiple filesystems on LVM on a single SATA hard drive. This disk ran out of space and I wanted more reliability so I decided to install two additional large drives in the system and mirror them using RAID 1. Since I had originally configured the machine with LVM I was able to do most of this while the system was in production.

This procedure relies on several LVM features which are not terribly well-documented so I decided it would be a good idea to write down my procedure here to help others who are contemplating a similar upgrade.

Note that after all of this I left the original drive in the machine as the boot drive as it wasn't worth the extra effort to make the new raid array the boot drive as well. That could be done as a further optimization to increase reliability if desired.

Procedure

mv /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak
mkinitrd -v /boot/initrd-$(uname -r).img $(uname -r)
echo "DEVICE /dev/sdb1 /dev/sdc1" >/etc/mdadm.conf
mdadm --detail --scan >>/etc/mdadm.conf
echo "MAILADDR root@example.com" >>/etc/mdadm.conf