Increase File System Size of a Container

After creating a CentOS container in LXD running on CentOS 7.7. We wanted to increase the disk size. We did:

lxc config device override alextest root size=100GB
lxc config device set alextest root size 100GB

And the command “lxc config show – expanded alextest” shows root being 100GB. When we log into the container and do a “df -h” we do not see any change, the filesystems are all the same size as before.

I assume we now need to expand the filesystem inside the container or create a new filesystem using the free space from the 100GB. How do we do that?


What storage backend is that?

For LVM & Ceph, a restart of the container is required in order to increase the size of the underlying volume and filesystem.

I am not sure, I think we have LVM, we do have it installed on the host. Is there a way to confirm which we are using?

We have a filesystem that is 1.4 TB, we would like to use that to store our containers in, it is empty, I can remove it and rebuild it if needed.

I guess I’m asking what is the best way to do that? Then we will want our containers to have a size of 100GB.


lxc storage list would tell you, lxc storage show default should tell you more about what’s used.

In general, the most flexibility (and least wasted space) you’d get is using ZFS as the container size would then just be a quota rather than a hard allocation. It also does some convenient things like compression and copy on write and because it’s all done in the filesystem, all limits can be changed live with no issue.

LVM as a backend certainly work, a VG is taken by LXD, thinpool is used to give some amount of copy on write and LVs are created for each container using the size property on the root device as the default size for this. Growing requires a restart of the container though and depending on the filesystem used, shrinking may or may not be possible (xfs doesn’t allow it, ext4 and btrfs are fine with it).

Will I need to install some ZFS tools on the host?
To use ZFS, I specify it in the “lxd init” command?


Well, ZFS is not an option in “lxd init” so we picked lvm. :slight_smile:

Ah, you may be on a kernel which doesn’t offer it.

At least with version 3.21 there is still an issue with the lvm driver and xfs Filesystem, at least if running on CentOS (7&8) and Fedora (29-31). Don’t know about other distros.

First you have to expand the filesystem using LXD tools as described in the initial message. You get an error message, that the filesystem could not get extended. The usual LXD tools report inaccurate meta data.

Then you have to stop the container and you MUST NOT restart it until you get the problem fixed! Otherwise the container will never start again (at least not using the LXD tools).

To fix the issue mount the container lv anywhere in the file system, expand it using the standard xfs tool und unmount it.

Now you may start the container again and anything is just fine.

With the EXT4 file system anything works fine, no need to fix anything.