Customer SupportShop

Expand a Linux LVM logical volume

Grow a Linux LVM-backed file system in the correct order: disk, partition where present, physical volume, logical volume and file system.

Applies to: An Ubuntu LVM disk using the device paths shown in this example and an ext4 file system.

Before you start

  • Have a current, recoverable backup, console access and a maintenance plan. Confirm the exact disk, partition, PV, VG, LV and file-system type before changing storage.
  • The example assumes a simple, non-encrypted, non-thin LVM layout using partition /dev/sda3 and LV /dev/ubuntu-vg/ubuntu-lv. Replace both with the verified paths. Other layouts need their own procedure.

Procedure

  1. Increase the underlying virtual or physical disk using its supported storage-management procedure.
  2. Open cfdisk and check that Linux can see the additional disk space. If it cannot, use the rescan command below for the example sda disk.
  3. In cfdisk, select the partition to expand, choose Resize and write the new partition table. Preserve the start sector and partition type. Check the system recognises the new size before continuing.
  4. Check and resize the physical volume, then use the volume-group display to confirm the free space is available.
  5. Find the intended logical-volume path and extend it. The original command uses +100%FREE to allocate all remaining free space in its volume group.
  6. Check the file-system path with df -h, grow the ext4 file system with resize2fs, then run df -h again to confirm the new size.

Commands

1. Rescan the example disk

echo 1 > /sys/class/block/sda/device/rescan

2. Display and resize the physical volume

sudo pvdisplay
sudo pvresize /dev/sda3

3. Check free space in the volume group

sudo vgdisplay

4. Find the logical-volume path

sudo lvdisplay

5. Extend the logical volume using the free space

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

6. Check the file-system path and current size

df -h

7. Resize the file system

In this example the file system is /dev/mapper/ubuntu--vg-ubuntu--lv.

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

8. Check the new file-system size

df -h

Check the result

  • Confirm the expected free space and volume sizes in the output from vgdisplay, lvdisplay and df -h.
  • Check application reads and writes and backup health after the change.

Screenshots

These screenshots show the interface used for the original guide. Labels and available options may differ in your release.

Expand a Linux LVM logical volume — screen 1
Expand a Linux LVM logical volume — screen 1
Expand a Linux LVM logical volume — screen 2
Expand a Linux LVM logical volume — screen 2
Expand a Linux LVM logical volume — screen 3
Expand a Linux LVM logical volume — screen 3
Expand a Linux LVM logical volume — screen 4
Expand a Linux LVM logical volume — screen 4
Expand a Linux LVM logical volume — screen 5
Expand a Linux LVM logical volume — screen 5
Expand a Linux LVM logical volume — screen 6
Expand a Linux LVM logical volume — screen 6
Expand a Linux LVM logical volume — screen 7
Expand a Linux LVM logical volume — screen 7
Expand a Linux LVM logical volume — screen 8
Expand a Linux LVM logical volume — screen 8
Expand a Linux LVM logical volume — screen 9
Expand a Linux LVM logical volume — screen 9