LVM allows you to hot add devices to expand volume space. It also allows you to hot remove devices, as long as there are enough free extents in the volume group (vgdisplay) to move data around. Here I’m going to replace a 400 GB drive (sdg) with a 750 GB one (sdh) from logical volume “backup” on volume group “disks”. It does not matter how many hard drives are in the volume group, and the filesystem can stay mounted.
- Partition and create a physical volume on the device
$ sudo pvcreate /dev/sdh1
- Add the new drive to the volume group
$ sudo vgextend disks /dev/sdh1
- Move all extents from the old drive to the new one (this step may take hours)
$ sudo pvmove -v /dev/sdg1
- Remove the old drive
$ sudo vgreduce disks /dev/sdg1
- Expand the logical volume to use the rest of the disk. In this case, another 350GB.
$ sudo lvextend -l+83463 /dev/disks/backup
- Expand the file system
$ sudo resize2fs /dev/disks/backup $ sudo xfs_growfs /dev/disks/backup