Replace an LVM Drive with a Larger One

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.

  1. Partition and create a physical volume on the device
    $ sudo pvcreate /dev/sdh1
  2. Add the new drive to the volume group
    $ sudo vgextend disks /dev/sdh1
  3. Move all extents from the old drive to the new one (this step may take hours)
    $ sudo pvmove -v /dev/sdg1
  4. Remove the old drive
    $ sudo vgreduce disks /dev/sdg1
  5. Expand the logical volume to use the rest of the disk. In this case, another 350GB.
    $ sudo lvextend -l+83463 /dev/disks/backup
  6. Expand the file system
    $ sudo resize2fs /dev/disks/backup
    $ sudo xfs_growfs /dev/disks/backup

3 Replies to “Replace an LVM Drive with a Larger One”

Comments are closed.