Skip to content

Extend an LVM volume ​

After the disk or the partition that holds the physical volume grows, LVM does not pick up the extra space by itself. Extend each layer from the bottom up: physical volume, logical volume, filesystem.

After a VPS upgrade the disk is expanded automatically; this guide is for the cases where that did not happen, or where you resized the disk yourself.

WARNING

Back up critical data before you change disks, partitions or LVM metadata. A mistake at any layer can make the volume unmountable.

Find the names on your system ​

Confirm the actual names before running anything below:

bash
lsblk
sudo pvs
sudo vgs
sudo lvs

The rest of this guide uses a typical Ubuntu install:

Disk/dev/sda
LVM partition/dev/sda3
Volume groupubuntu-vg
Logical volumeubuntu-lv
Mount point/

Step 1: confirm the OS sees the new size ​

bash
lsblk

If the disk reports the new size and the partition does not, grow the partition first (growpart, parted, or fdisk) before continuing.

Step 2: resize the physical volume ​

bash
sudo pvresize /dev/sda3

Confirm there is now free space inside the volume group:

bash
sudo vgs

The VFree column should be non-zero.

Step 3: extend the logical volume ​

To use all available free space:

bash
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Or to grow by a specific amount, e.g. 20 GiB:

bash
sudo lvextend -L +20G /dev/mapper/ubuntu--vg-ubuntu--lv

Step 4: resize the filesystem ​

ext4:

bash
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

xfs (online resize, mount path):

bash
sudo xfs_growfs /

Step 5: verify ​

bash
df -h
sudo pvs
sudo vgs
sudo lvs

The mount point should now report the new size. If lsblk still shows the old partition size, the disk-level resize step was not picked up - confirm with dmesg | tail or reboot.

Gigahost Docs

This site is currently in development.
Enter the password to continue.