Clone/Replace HDD in Software RAID

When replacing hdd in software raid, easiest way to do it is to clone partition table from the healthy disk on the new one. Regenerate UUIDS and add new disk in the array.

Here's how we do it. (/dev/sda is healthy disk)

For MBR Disks:

# sfdisk -d /dev/sda | sfdisk /dev/sdb

also can do a partitions rescan:
# sfdisk -R /dev/sdb

For GPT Disks:

# sgdisk -R /dev/sdb /dev/sda

then set new UUIDs

# sfdisk -R /dev/sdb

then check if partitions have appeared:

# fdisk -l /dev/sdb

after that simply add your partitions:

# mdadm /dev/md0 -a /dev/sdb1
....add all md dev-disk pair...

then you can watch it syncing:

# watch cat /proc/mdstat

afterwards don't forget to install grub:

# grub-install /dev/sdb