Root partition size in profile not applied to vm

Maybe I’m doing something wrong here.
I have this profile

lxc profile show vmprofile
config: {}
description: VM LXD profile
    name: eth0
    network: lxdbr0
    type: nic
    path: /
    pool: vmpool
    size: 20GB
    type: disk
name: vmprofile
- /1.0/instances/vmk

and I created this instance

lxc launch images:ubuntu/focal vmk --vm -p vmprofile

however, inside instance

/dev/sda2       3.8G  721M  3.0G  20% /

how can I make the root partition be 20GB?

Can you show cat /proc/partitions?

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

   8        0   19531248 sda
   8        1     102400 sda1
   8        2    4090863 sda2

here is complete df -h

root@vmk:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            478M     0  478M   0% /dev
tmpfs            98M  604K   98M   1% /run
/dev/sda2       3.8G  721M  3.0G  20% /
tmpfs           490M     0  490M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           490M     0  490M   0% /sys/fs/cgroup
/dev/sda1        99M  3.9M   95M   4% /boot/efi
config           19G  7.0M   19G   1% /run/lxd_config/9p

Ok, so your disk is indeed 20GB large, so that worked fine.
Unlike with containers, all LXD can do is grow your disk and partition table, it can’t do the partition resizing for you.

You can use something like growpart (cloud-guest-utils package) to grow your /dev/sda2 to fill the partition table, then reboot and extend the filesystem to match.

That’s something like growpart /dev/sda 2 and after reboot resize2fs /dev/sda2

1 Like

Note that the cloud images will do that automatically for you during boot.

So using images:ubuntu/focal/cloud which comes with cloud-init and growpart should boot with the full 20GB, while images:ubuntu/focal which does not, will boot with the default 4GB and require you to handle growing it.

1 Like

cool, growpart and resize2fs did the job :slight_smile:
just curious, why not using the same approach with images:ubuntu/focal (auto growpart…)?

Because the logic that brings it in (cloud-init) is quite large, that’s why we have the separate cloud image.

Also, not everyone wants this behavior. If you want to actually partition things to have multiple partitions, having it auto-grow on you at boot is a bit unfortunate.

thanks again for quick support!