I spent a long time finding out how to create a RAID array where one drive already contained data that I wanted in the array.
Heres how to do it. Both drives should be formatted to ext4 and not mounted (you can try a different drive format but I havent tested it)
Note: Be sure to backup your data just in case something happens! You've been warned
Lets assume /dev/sda1 contains the data, and /dev/sdb1 is the empty drive
sudo bash
# wipe the empty drive
sfdisk -d /dev/sda1 | sfdisk /dev/sdb1
# create the array the missing drive is the one containing data
sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 missing
# create the filesystem on the RAID array
sudo mkfs.ext4 /dev/md0
# mount the RAID array
sudo mount -t ext4 /dev/md0 /media/raid1
# mount the drive containing the data
sudo mount -t ext4 /dev/sda1 /media/tb1
# copy data to empty portion of RAID1 using whichever arguments of rsync you prefer
rsync -av /media/tb1/ /media/raid1
# unmount drive containing data (not part of RAID set)
sudo umount /media/tb1
# now add that drive to the array
sudo mdadm --add /dev/sda1
Now wait for it to sync, and then setup mount on startup via fstab.
**Thanks to joberly @ Ars Technica Forum for this
Related External Links: