Expand LXC container filesystem

I can’t figure out how to resize an LXC container filesystem. I’ve already overridden the default block storage device size, but I can’t “see” the block storage device inside the container.

# zfs get all default/containers/mycontainer
default/containers/mycontainer     used                  12.7G
default/containers/mycontainer     referenced            13.0G
default/containers/mycontainer     quota                 30G

How do I get the filesystem on the ZFS device to “fill” the 30GB of space?

I tried using cfdisk inside the container, and it doesn’t “see” the filesystem. lsblk doesn’t show the filesystem.

I already set autoexpand on, for the default ZFS pool, so that shouldn’t be an issue. I’m just trying to resize this one container disk.

1 Like

You use

lxc config device (set|override) (instance) root size=nGiB

Yes, I already know how to resize the block device. However, I can’t figure out how to expand the filesystem inside the container, after resizing the block device. :slight_smile: Any thoughts?

I figured it out. Finally found another thread with a similar issue.

It’s not clear from any documentation, but you have to run the truncate command to arbitrarily increase the zpool image size. Then you have to stop and restart LXD, so it “sees” the new ZFS pool size.

My container filesystem appears larger now, inside the container.

1 Like

Since that post you can also just do

lxc storage set (pool)  size=
3 Likes