Expanding a partition on an Ubuntu KVM VM

For next time I need to do this, and forget how, the easiest way to expand a partition inside a KVM virtual machine is to:
1. Boot onto an Ubuntu Live CD.
– Add a virtual CD drive if there isn’t one already, I used an ubuntu desktop iso, but anything with GParted will do.
– Set the boot priority to try the CD drive first.
– Reboot the VM2. Resize the Partition
– Open up gparted
– Move any partitions that may be in the way of the one you want to expand
– Expand the desired partition
– Apply the changes

3. Resize the Filesystem
– Remove the CD drive/change the boot order to boot from the hard drive again
– Reboot the VM back into the Native OS
– Run resize2fs with the drive you need to expand, eg resize2fs /dev/sda1

Done!