Home > file systems, howto, LVM > Replace an LVM Drive with a Larger One

Replace an LVM Drive with a Larger One

March 21st, 2009

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
Categories: file systems, howto, LVM
  1. Dale
    October 31st, 2013 at 16:56 | #1

    Hmm. You state: “…replace a 400 GB drive (sdg) with a 750 GB one (sdf) …”. Don’t you really mean (sdh)?

  2. July 10th, 2016 at 22:51 | #2

    Yes. Fixed, thanks.

Comments are closed.