[CentOS] Replacing SW RAID-1 with SSD RAID-1

Mon Nov 23 16:04:28 UTC 2020
Phil Perry <pperry at elrepo.org>

On 23/11/2020 15:49, Frank Bures wrote:
> On 11/23/20 10:46 AM, Simon Matter wrote:
>>> Hi,
>>> I want to replace my hard drives based SW RAID-1 with SSD's.
>>> What would be the recommended procedure?  Can I just remove one drive,
>>> replace with SSD and rebuild, then repeat with the other drive?
>> I suggest to "mdadm --fail" one drive, then "mdadm --remove" it. After
>> replacing the drive you can "mdadm --add" it.
>> If you boot from the drives you also have to care for the boot loader. I
>> guess this depends on how exactly the system is configured.
> Thanks, that's what I had in mind.  Of course, I will rebuild grab2 
> after each iteration.
> Thanks
> Fra

You could also grow the array to add in the new devices before removing 
the old HDDs ensuring you retain at least 2 devices in the array at any 
one time. For example, in an existing raid of sda1 and sdb1, add in sdc1 
before removing sda1 and add sdd1 before removing sdb1, finally 
shrinking the array back to 2 devices:

mdadm --grow /dev/md127 --level=1 --raid-devices=3 --add /dev/sdc1
mdadm --fail /dev/md127 /dev/sda1
mdadm --remove /dev/md127 /dev/sda1
mdadm /dev/md127 --add /dev/sdd1
mdadm --fail /dev/md127 /dev/sdb1
mdadm --remove /dev/md127 /dev/sdb1
mdadm --grow /dev/md127 --raid-devices=2

then reinstall grub to sdc and sdd once everything has fully sync'd:

blockdev --flushbufs /dev/sdc1
blockdev --flushbufs /dev/sdd1
grub2-install --recheck /dev/sdc
grub2-install --recheck /dev/sdd