HOWTO+-+Create+a+Software+RAID+1+from+an+Existing+Installation

A: If you are trying to mirror a data drive. Assumption, existing data drive is /dev/sdb and new drive is /dev/sdc. 1. Make sure your kernel had RAID support and both md_mod & raid1 modules are loadable. 2. With fdisk, create a new partition of type fd on your new drive. 3. Initialize a degraded RAID1 array: //mdadm -C /dev/md0 --force --level=1 --raid-devices=2 /dev/sdc1 missing //. 4. Create a filesystem on /dev/md0: //mkfs -t ext3 /dev/md0 //. 5. At this point, /dev/md0 is fully usable. Mount /dev/md0 and copy the contents of /dev/sdb to /dev/md0. 6. Unmount /dev/sdb and mount /dev/md0 in /dev/sdb mount point. 7. With fdisk, repartition /dev/sdb with a partition of type fd. 8. Add /dev/sdb1 to your existing RAID1 array: //mdadm /dev/md0 --add /dev/sdb1 //. *I encountered a problem with adding the old drive to the array this morning if I didn't create a filesystem on it first. I don't recall doing this the last time. 9. Array will now start to rebuild. Use //<span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">mdadm -D /dev/md0 //<span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;"> to check its rebuild status. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">10. Edit your /etc/fstab file and edit all references of /dev/sdb to /dev/md0. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">* No reboot is required. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">** It may be possible "upgrade" to a RAID5 in future by breaking your RAID1 and pairing the "broken" (/dev/sdd?) drive to another new drive (/dev/sde?) to form a degraded RAID5 and copying the data from /dev/md0. Finally adding /dev/sdc back into your new RAID5 array to rebuild.

<span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">B: If you are trying to mirror an OS drive. Assumption, OS drive is /dev/sda and new drive is /dev/sdb <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">1. Repeat steps A1 to A5. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">2. Repeat step A10. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">3. Install grub on /dev/sdb to make it bootable. Run: //<span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">grub-install /dev/sdb //<span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">. (I may be wrong here!) <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">5. Shutdown your system and swap your drives. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">6. Power up your system and repeat step A8. <span style="background-color: #dedeff; font-family: Tahoma,Arial,Helvetica,sans-serif;">* This method was my first attempt to create a RAID1 array on an existing system with data with only 2 drives! It was trial and error trying really hard to loose any data. My memory is a bit vague about that attempt. Method A was a second attempt which proved successful.