Available storage inside the container when device size is configured

Hello,

Is it possible to have a container seeing the available storage on a device equal to the size defined in the container definition instead of the full available storage of the pool the device belongs to?

In the following example I would like container guest to show Avail=10G instead of Avail=875G when issuing df -hT / in it.

user@host:~$ lxc storage list
+--------+--------+--------------+-------------+---------+
|  NAME  | DRIVER |    SOURCE    | DESCRIPTION | USED BY |
+--------+--------+--------------+-------------+---------+
| pool01 | btrfs  | /media/lxdsp |             | 7       |
+--------+--------+--------------+-------------+---------+
user@host:~$ df -hT /media/lxdsp/
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      btrfs  887G  9,9G  875G   2% /media/lxdsp
user@host:~$ lxc config device get guest root size
10GB
user@host:~$ lxc exec guest bash
root@guest:~# df -hT /
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      btrfs  887G  9.9G  875G   2% /

I know that the storage quota should be enforced in any case, but still I would like if this behaviour is at all possible, even if with other storage backends and/or configuration.

Thanks in advance!

Hi @pmarini,
You can check the expanded configuration of the container like that, lxc config show guest --expanded and add / override the root disk size as well.
lxc config device override quest root size=15GB
You can adjust the root disk size in your requirement, here is the document link.
https://linuxcontainers.org/lxd/docs/master/storage/
Regards.

Hi @cemfazer.

Thanks for the reply but this is not my question.

What I want to understand is if it is possible and makes sense to have the df -hT inside the container reflecting the size set in the host.

By default BTRFS volumes do not have a quota enforced, this is why you are seeing the full storage pool size available.

Have you tried setting a quota as @cemzafer suggested?

Yes I tried. Everything works fine, quota is enforced, meaning that trying to push a file larger than the quota makes the operation fails.

My concern is to expose this information also to the df utility inside the container, “Avail” field.

btrfs unfortunately does not expose quotas through the statvfs syscall and so df will never show a btrfs quota.

That’s different from what ext4/xfs/zfs/… all do where the filesystem stat information reflects the quota in place.

2 Likes

Ok, thanks for the clarification.

If there is some good read comparing storage backend types for LXD apart of the Storage configuration page, I would be glad to know.