There comes a time when RAID1 outlives its usefulness and it’s time to ‘upgrade’ to the more expandable RAID5. So what’s the simplest way of migrating existing RAID1 partitions to RAID5? Well it’s actually less painful than you might think.
As ever please backup any critical data to a separate drive before you undertake this. I have performed this on a Fedora 12 system and it completed without a hitch, but YMMV!
I recommend that you boot from a Fedora rescue disc so you’re not doing this on a ‘live’ system, then drop to the command prompt shell and follow these instructions:
Stop the existing RAID array:
# mdadm --stop /dev/md0
Create the new RAID5 array (cat /proc/mdstat to check on rebuild progress):
# mdadm --create /dev/md0 --level=5 -n 2 /dev/sda2 /dev/sdb2
Add an additional disk to the new RAID5 array:
# mdadm --add /dev/md0 /dev/sdc2
Now grow the partition to include the extra disk (again cat /proc/mdstat to check progress). This make take several hours depending on the size of the partition. The backup file can be used to restore data in the event of a system crash and should be stored on a separate device.
# mdadm --grow /dev/md0 --raid-disks=3 --backup-file=/mnt/ext/raid5.bak
Perform an integrity check on the new RAID filesystem:
# e2fsck -f /dev/md0
Then resize the partition to include the extra disk space:
# resize2fs -p /dev/md0
Add the new RAID configuration to mdadm.conf and create a new ramdisk image:
# chroot /mnt/sysimage
# mdadm --examine --scan | grep md0 >>/etc/mdadm.conf
# dracut -f /boot/initramfs-$(uname -r).img $(uname -r)