Resizing a Linux VM disk live, without LVM

There are many guides online for growing a VM disk, but they assume you’re using LVM or do scary things with fdisk.

This method works without a reboot, even on your root filesystem, and shouldn’t cause downtime if you do it to the wrong partition or disk (but could cause annoyance). It assumes you’re using EXT4; otherwise, replace resize2fs with the equivalent command for your filesystem of choice.
It also won’t work unless the partition you’re resizing has free space directly after it on the disk.

First resize the disk image on the hypervisor/host, then inside the VM run these commands:

sudo growpart /dev/sdX Y
sudo resize2fs /dev/sdXY

Where sdX is your VM’s drive (sda, vda, etc) and Y is the partition number.

For example, let’s say your lsblk looks like this:

NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
vda    252:0    0    95G  0 disk
├─vda1  252:1    0    1M  0 part
└─vda2  252:2    0   95G  0 part /

But df -h shows this:

Filesystem   Size  Used Avail Use% Mounted on
/dev/vda2    45G   33G 9.6G  78%  /

Just run this:

sudo growpart /dev/vda 2
sudo resize2fs /dev/vda2

Run df -h again, and it’s done!

Filesystem   Size  Used Avail Use% Mounted on
/dev/vda2    94G   33G  57G  37%  /