How to Extend a Disk or Partition on Linux (growpart, LVM and resize2fs)

Ubuntu only used half the disk? Grow it online. No reboot.

Two very common situations: you enlarged a VM's disk in Proxmox or your cloud provider and Linux still reports the old size; or you installed Ubuntu Server with the default LVM option and later discover it only used half the drive. Either way, the fix is three commands and no reboot — once you know which layer needs growing.

Quick reference

LayerCommand
See the layoutlsblk and df -h
1. Grow the partitionsudo growpart /dev/sda 3
2a. LVM: grow the volumesudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
3. Grow the filesystem (ext4)sudo resize2fs /dev/ubuntu-vg/ubuntu-lv (or /dev/sda3 without LVM)
3. Grow the filesystem (xfs)sudo xfs_growfs /

1. Look at the layers

lsblk
df -h /

Typical Ubuntu Server with LVM:

sda 100G
├─sda1 1G /boot/efi
├─sda2 2G /boot
└─sda3 97G
└─ubuntu--vg-ubuntu--lv 48G /

Three layers: the partition (sda3), the LVM logical volume inside it (ubuntu-lv), and the filesystem on that. Each must be grown in turn. Without LVM there are only two: partition and filesystem.

2. Grow the partition

Only needed if the disk got bigger (the VM case). If sda3 already fills the disk, skip to step 3.

sudo apt install cloud-guest-utils -y
sudo growpart /dev/sda 3

Note the space between disk and partition number. lsblk should now show sda3 filling the disk. This is safe to do online.

3. Grow the LVM volume

The classic Ubuntu-installer case: sda3 is 97 GB but the logical volume is 48 GB.

sudo pvresize /dev/sda3 # tell LVM the partition grew (harmless if it didn't)
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

+100%FREE uses all the space; -L +20G would add 20 GB and keep the rest for a second volume later.

4. Grow the filesystem

sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
df -h /

For a system without LVM: sudo resize2fs /dev/sda3. For XFS (some cloud images): sudo xfs_growfs /. Both work on a mounted, running system.

Data drives without LVM

A second drive that grew (bigger VM disk, or a cloud volume resized):

sudo growpart /dev/sdb 1
sudo resize2fs /dev/sdb1

Same two steps, no LVM in between.

Making a second volume instead

If you'd rather keep free space for a separate /home or /var/lib/docker:

sudo lvcreate -L 40G -n docker-lv ubuntu-vg
sudo mkfs.ext4 /dev/ubuntu-vg/docker-lv

Then mount it via fstab (tutorial 22) using the UUID from blkid.

Shrinking

Growing is online and safe. Shrinking ext4 requires unmounting (boot from a live USB for /), and XFS can't shrink at all. Plan sizes generously and avoid it.

Troubleshooting

growpart says "NOCHANGE". The partition already fills the disk. Move to the LVM/filesystem step.

lvextend says "Insufficient free space". pvresize wasn't run after growing the partition, or the volume group has another volume using the space (sudo vgs, sudo lvs).

resize2fs says "Nothing to do". Filesystem already fills the volume; the free space is in a different layer. Walk back through lsblk.

Disk grew in the hypervisor but lsblk shows the old size. Rescan: echo 1 | sudo tee /sys/class/block/sda/device/rescan.

It's a GPT disk and growpart complains about the backup header. sudo sgdisk -e /dev/sda moves it to the end, then retry.

Wrapping up

lsblk to see the layers, growpart for the partition, lvextend for the volume, resize2fs for the filesystem. All online, all reversible-in-the-sense-of-harmless, and the "Ubuntu only used half my disk" mystery is solved in a minute.

Call us