How to resize a root volume in Alpine LInux

How to resize a volume in incus for alpine linux

Sometimes when you use default instance types in incus, the default root volume is too low. This mostly applies to alpine linux, which has a default root volume size of only 2gb! Be sure to do the INCUS commands first!

Steps:

  1. install cloud-utils-growpart
  2. install e2fsprogrs-extra
  3. growpart /dev/sda 2
  4. resize2fs /dev/sda2

On the incus side you need to run some commands too:

incus config device override <vm name> root size=<sizeingb>50Gib

This stop the vm restart it, and then do the top steps and POOF nice big volume.

Or you can avoid that complexity if you use the “cloud” variant, as cloud-init sorts this for you.

# incus launch images:alpine/edge/cloud foo --vm -c security.secureboot=false -d root,size=15GiB

# incus exec foo -- df -k /
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             15068900    316228  14736288   2% /