Archive

Archive for March, 2009

Replace an LVM Drive with a Larger One

March 21st, 2009 2 comments

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
    1
    
    $ sudo pvcreate /dev/sdh1
  2. Add the new drive to the volume group
    1
    
    $ sudo vgextend disks /dev/sdh1
  3. Move all extents from the old drive to the new one (this step may take hours)
    1
    
    $ sudo pvmove -v /dev/sdg1
  4. Remove the old drive
    1
    
    $ sudo vgreduce disks /dev/sdg1
  5. Expand the logical volume to use the rest of the disk. In this case, another 350GB.
    1
    
    $ sudo lvextend -l+83463 /dev/disks/backup
  6. Expand the file system
    1
    2
    
    $ sudo resize2fs /dev/disks/backup
    $ sudo xfs_growfs /dev/disks/backup
Categories: file systems, howto, LVM