Date

Some technical notes on migrating from 3-disk raid5 to raid1 without dataloss or reformatting.

My setup: I had a 3-disk raid5 ( 500GBx3, giving 990ish GB of usable space)

*) Empty enough space, you need to go down to the smallest disk in your collection, in my case, cleaned out to some 340GB used space, simply because I could.

*) fsck, need to be done before resize.
fsck -f /dev/md0

*) resize the filesystem so it's smaller than the disk size. Preferably with some margin.
resize2fs -p /dev/md0 400G
( this takes _TIME_ around 1.4Meg/second total )

*) pretend-shrink the array
mdadm --grow /dev/md0 --array-size=471859200

*) fsck-test ( read-only to check you don't lose any data)
fsck -n -f /dev/md0

*) reduce the array to a two-disk raid5 (takes time, needs to do a full recovery, approx 22MB/sec )
mdadm --grow /dev/md0 --backup-file=/root/backup-mdadm --raid-devices=2

*) transform from a 2disk raid5 to a 2disk raid1
mdadm --grow /dev/md0 --level=raid1 --backup-file=/root/backup-raid5

*) resize the filesystem to fill the whole raid
mdadm --grow /dev/md0 --size=max
resize2fs -p /dev/md0

*) remove the spare device from your set.

After that, I just moved one of the drives into the other system, activated it as degraded, copied my files over, and resynced it all.