Cannot change VM root disk size

I’m following Running virtual machines with LXD 4.0 to start an Ubuntu Focal VM.

I then run the following to get more CPU and RAM (as a tangent, the listed defaults on https://linuxcontainers.org/lxd/docs/master/instances are wrong).

lxc config set banana limits.cpu 8     
lxc config set banana limits.memory 8GB 

I can see these reflected once I start the VM. However, I also run

lxc config device add banana root disk pool=default path=/ size=100GB

but this isn’t reflected inside the VM

root@banana:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.7G     0  3.7G   0% /dev
tmpfs           741M  688K  740M   1% /run
/dev/sda2       3.8G  730M  3.0G  20% /
tmpfs           3.7G     0  3.7G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/sda1        99M  3.9M   95M   4% /boot/efi
config          9.4G  8.0M  9.4G   1% /run/lxd_config/9p

I’m using ZFS as the pool provider.

Unlike containers, VMs use block devices that are not managed by LXD itself, so you need to update and grow your partitions in the VM.

cat /proc/partitions will show the full block size, then use something like growpart to resize your partition table and partitions.

I have also tried to set this in the profile:

  root:
    path: /
    pool: default
    size: 100GB
    type: disk

It also gives me the same 3.8GB root.

Thanks, I’ll try that now.

@stgraber is there another step I need to do (I’ve tried rebooting)?

root@banana:~# cat /proc/partitions 
major minor  #blocks  name

   8        0   97656248 sda
   8        1     102400 sda1
   8        2    4090863 sda2
   8       16        356 sdb

root@banana:~# growpart /dev/sda 2
CHANGED: partition=2 start=206848 old: size=8181727 end=8388575 new: size=195105615 end=195312463

root@banana:~# cat /proc/partitions 
major minor  #blocks  name

   8        0   97656248 sda
   8        1     102400 sda1
   8        2   97552807 sda2
   8       16        356 sdb

root@banana:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.7G     0  3.7G   0% /dev
tmpfs           741M  696K  740M   1% /run
/dev/sda2       3.8G  839M  2.9G  23% /
tmpfs           3.7G     0  3.7G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/sda1        99M  3.9M   95M   4% /boot/efi
config           94G  7.0M   94G   1% /run/lxd_config/9p

In case anyone else has this issue, you need to run resize2fs /dev/sda2 after growpart /dev/sda 2

Script to do this here https://gist.github.com/joedborg/2ad747923104273c79dda76fe5063ce2