I need to move a server mdadm RAID1 setup on a new pair of bigger disks, from 2TB to 4TB. The disks are GPT with 4 partitions:
/dev/nvme1n1p1 /dev/md0 biosboot /dev/nvme1n1p2 /dev/md1 swap /dev/nvme1n1p3 /dev/md2 /boot /dev/nvme1n1p4 /dev/md3 / I also need to expand md1 a bit and md3 to fill the remaining space.
How should I proceed to mirror the data to the new disks without risking to lose anything?
Since the raid is created on the partitions, can I just recreate the partition with different sizes and add them to the array or they need to have the exact starting block of the old disk?
What I thought to do (I'm using the MD numbering here but I'm referring to the actual partition [ie. md0 is nvme2n1p1]):
Create the partitions on the new disks. Creating md0, md2 and md3 of the same size. md1 will be created initially with the new increased size so md2 and md3 will have different starting block. Then md1 will be deleted and recreated to have the same size as old drive. This leaves me in a state with all the partitions of the same old size but moved on the disk for later.
Add the new partitions, one new disk at time, to the old array. Failing one of the old drive I get to resync them to mirror the data.
Once both new disks are mirrored I fail\remove the old ones. So the array remains with only the new one.
Proceed to install grub on the new drives and update initramfs. Also check fstab for any issues.
Expand the mdadm raid size for md1 and md3. Then use the filesystem utils to resize them too (XFS).
Reboot and pray
Would it work?
The alternative is to recreate a completely new array on the new disks and rsync every partition.