3 Sep 27, 2016 — https://sf.gl/1389

How to extend a LVM volume group

Extending a logical volume group usually needs to be done when the size of a VMware disk has been increased for a Linux VM. When resizing a disk, the volume isn't extended automatically, so you need to extend the logical volume in the VM's volume group.

This article assumes that:

  • You have a LVM volume group with a logical volume
  • You've added free space in the virtualizer, e.g. VMware
  • You're running Ubuntu. Might also work with other distributions
  • You have basic knowledge of partitions and Linux

Creating new partition with Gparted

  1. Start by creating a new partition from the free space. I prefer doing this with a GUI using gparted. You need XQuartz if you're on a Mac.
    1. SSH into the box with -X, e.g. ssh -X myserver
    2. Install gparted: apt-get install -y gparted and run gparted
    3. Find the unallocated space ("unallocated" file system)
    4. Right click and click New.
    5. Create as "primary partition" and Choose lvm2 pv  as the "file system"
    6. Click Add
    7. Click Apply in the toolbar and again in the dialog
    8. Note the disk name in the Partition column, e.g. /dev/sda3
  2. You should see the disk with fdisk -l
  3. Run pvcreate <disk>, e.g. pvcreate /dev/sda3
  4. Find the volume group: run vgdisplay (name is where it says VG Name)
  5. Extend the VG with the disk: vgextend <vg name> <disk>, e.g. vgextend VolumeGroup /dev/sda3
  6. Run vgscanpvscan
  7. Run lvdisplay to find the LV Path, e.g. /dev/VolumeGroup/root
  8. Extend the logical volume: lvextend <lv path> <disk>, e.g. lvextend /dev/VolumeGroup/root /dev/sda3
  9. Resize the file system: resize2fs <lv path>, e.g. resize2fs /dev/VolumeGroup/root
  10. Finally, verify that the size of the partition has been increased with df -h

3 Responses to “How to extend a LVM volume group”

  1. How to Increase Size of Root Partition in CentOS - Sajjan's Blog

    […] How to extend a LVM volume group […]

  2. Marabiloso

    It kinda works with Linux Mint 18 (kernel 4.15) on ESXi 6.0 (Workstation or Fusion may behave differently)… Except it doesn’t see the added space on /dev/sda (even with the refresh function in gparted) until you reboot. However, adding a disk (e.g. /dev/sdb) works flawlessly on a running system.

  3. Jeroen

    Thanks for the clear step-by-step instructions!

Leave a Comment




Note: Your comment will be shown after it has been approved.