Resizing a disk on Ubuntu live can be really useful when uptime is a necessity.
This guide covers two scenarios: a disk using LVM (Volume Groups) and a plain ext4 partition with no LVM. In both cases, assumes EXT4 as the filesystem type and that you've already added the space to the disk itself (e.g. via your hypervisor).
With LVM (Volume Group)
Before LVM can use the new space, the partition and physical volume need to know about it first.
Confirm Partitions:
fdisk -l
Disk /dev/vda: 10.86 TiB, 11940009082880 bytes, 23320330240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Device Start End Sectors Size Type
/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 2101247 2097152 1G Linux filesystem
/dev/vda3 2101248 19025360895 19023259648 8.9T Linux filesystem
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 8.86 TiB, 9739907891200 bytes, 19023257600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
/dev/vda3 is the target partition we want to expand.
First we need to resize the partition first, then the PV on top of it:
sudo growpart /dev/vda 3
# CHANGED: partition=3 start=2101248 old: size=19023259648 end=19025360896 new: size=23318228959 end=23320330207
sudo pvresize /dev/vda3
# Physical volume "/dev/vda3" changed
# 1 physical volume(s) resized or updated / 0 physical volume(s) not resized
Now extend the logical volume and resize the filesystem:
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
That's it! No reboot needed.
Without LVM (Plain ext4)
If your disk has no LVM — just a partition directly formatted as ext4 — the process is simpler. A layout like this is common on VMs provisioned without LVM:
Device Start End Sectors Size Type
/dev/sda1 2048 2203647 2201600 1G EFI System
/dev/sda2 2203648 1048575966 1046372319 498.9G Linux filesystem
After expanding the disk in your hypervisor, rescan the SCSI bus so the kernel picks up the new size:
echo 1 > /sys/class/block/sda/device/rescan
Confirm the kernel sees the expanded disk:
fdisk -l /dev/sda
Grow the partition, then resize the filesystem directly:
sudo growpart /dev/sda 2
sudo resize2fs /dev/sda2
resize2fs supports online resizing of mounted ext4 filesystems, so no unmounting or rebooting is needed. Verify the result:
df -h /
That's it! No reboot needed.