Unable to set a disk size for / using btrfs

Hello,

I probably misconfigured something …
I want to set a disk size for the root (/) device.
But in the CT, I get the full host device size, /dev/md3, instead of a 100GB device :
-> lxc exec test – df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/md3 407G 298M 405G 1% /

Here is the default profile:
-> lxc profile show default
config: {}
description: Default LXD profile
devices:
root:
path: /
pool: default
size: 100GB
type: disk
name: default
used_by:

  • /1.0/containers/test

-> lxc storage list
±--------±------------±-------±-------±--------+
| NAME | DESCRIPTION | DRIVER | SOURCE | USED BY |
±--------±------------±-------±-------±--------+
| default | | btrfs | /btrfs | 3 |
±--------±------------±-------±-------±--------+

-> mount | grep btrfs
/dev/md3 on /btrfs type btrfs (rw,relatime,ssd,space_cache,subvolid=5,subvol=/)

Any help ?

Thank you !

Unlike ZFS, btrfs doesn’t render its quotas in the “df” output.

So your quota is applied to your container and btrfs should prevent you from exceeding it, but you won’t see it in the df output.

Also note that a user in the container can bypass btrfs quotas due to the unfortunate way qgroups work…

Ohhhh ok, sorry, I remember I read that already now…

Can we see the disk usage percent of the subvolume from the host ? (not inside the CT)

Thank you Stéphane !

root@lxd-demo01:~# btrfs qgroup show -reF /var/lib/lxd/storage-pools/default/containers/tryit-willing/
qgroupid         rfer         excl     max_rfer     max_excl 
--------         ----         ----     --------     -------- 
0/517       675.55MiB     40.55MiB         none     10.00GiB 

Not exactly the most user friendly command, but it does give you numbers :slight_smile:

Ok excellent :slight_smile:

Sorry, one more question:
I would like to add a second subvolume on the CT, so I have a “/data” mount point with a different disk space.

But:
-> lxc profile device add default data disk path=/data pool=default size=100GB source=/btrfs
error: Only the root disk may have a size quota.

Am I doing something wrong ? Or it is not possible ?

I found that a solution can be creating a btrfs subvolume manually, applying a quota on it, and then adding the device to the CT.

For those we are interested:
btrfs subvolume create /btrfs/data
btrfs qgroup limit 42G /btrfs/data
lxc config device add test default disk source=/btrfs/data path=/data

With LXD 2.16 you should also be able to use “lxc storage volume create POOL-NAME VOLUME-NAME size=42GB” and then use “lxc storage volume attach POOL-NAME VOLUME-NAME test /data” to attach it to your container.

Oh yes it looks better like this :slight_smile:

Thank you again