How to increase size of an ubuntu cloud image

I will be talking based on some quick QEMU experiments along the following setup: https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171

qemu-img

As of 18.04, the cloud images are already in qcow2 format, so the following seemed to work:

qemu-img resize ubuntu-18.04-server-cloudimg-arm64.img +128G

The guest appeared to immediately pick this new size up.

growpart

This script claims to make a given partition fill up as much space as possible and might be of use:

sudo apt-get install cloud-guest-utils
sudo growpart /dev/vda 1

It seems to run happily even though /dev/vda1 was mounted at /.


The growroot package is designed to do exactly that. http://packages.ubuntu.com/fr/trusty/admin/cloud-initramfs-growroot

If not already installed, add it with apt-get install cloud-initramfs-growroot and reboot your instance. The root partition will be expanded to the full size of your virtual disk (the one that you extended using qemu-img).