Replacing HDD RAID 1 with a larger HDD [ubuntu]

There is an Ubuntu 16.04 system that runs on Software Raid 1. What are the ways to replace all the HDDs in RAID 1 with more capacious ones? In short, you need to move the system from Software RAID 1 160G to Software RAID 1 500G.

Author: Vladimir, 2017-03-10

1 answers

The raid is probably collected via linux raid, better known as mdadm.

If it is possible to connect all 4 disks at once, then connect all the disks, mark them up as necessary. Then you expand the array to all 4 disks, raid1 you can easily change the number of disks in the array.

mdadm /dev/mdX -a /dev/sdcX
mdadm /dev/mdX -a /dev/sddX
mdadm --grow /dev/mdX -n 4

Waiting for the end of synchronization. After that, remove the old disks and narrow the array back to 2 disks.

mdadm /dev/mdX -f /dev/sdaX
mdadm /dev/mdX -r /dev/sdaX
mdadm /dev/mdX -f /dev/sdbX
mdadm /dev/mdX -r /dev/sdbX
mdadm --grow /dev/mdX -n 2

Everything, the array now lives on new disks, the old disks can be physically removed. disable it. Now you can tell mdadm to increase the size of the array with the command

mdadm --grow /dev/mdX --size=max

Further actions depending on what is located on the array. If the file system-then it depends on which file system: xfs_growfs, resize2fs or something else. If LVM-then the command pvresize can say that the size of the device has changed.

If it is possible to connect only two disks, then turn off one old one, add one new one, and wait for the array to synchronize, disconnect the second old disk, put the second new one. Then continue with --grow --size=max. To expand the array to new disks and only after synchronization to remove the old ones is a little more reliable for the border case when 1 disk was removed, and when syncing with the new one, the remaining old disk suddenly died.

 9
Author: Мелкий, 2017-03-10 14:58:13