Example for set storage limit

Hello,

I would like to set a limit for the disk space after I created a container (Ubuntu 20.04LTS). I didn’t use (because I don’t have the knowledge yet) any specific profile.

Could someone please provide me with an example how I could set this limit, because I tried 1000 things I found in the internet but nothing worked.

BR

1 Like

Hi,

What backend storage do you use?
With btrfs backend storage i do the following:

  • sudo lxc config device add container_name root disk pool=default path=/
  • sudo lxc config device set container_name root size 25GB

Hi,

thank you for the hint.

I use zfs as file system.

I used the second line without success and noticed on a couple of websites command line 1, but I am not sure what does it mean and why I need this ?

What does command line 1 do and what is the result ?

Hi Marc,
If you want to set a limit for a container you can give that command can solve the issue, i suppose.
lxc config device override <container_name> root size=5GB, for example.
You can check it out with the pleasant command lxc config show <container_name> --expanded.

Regards.

1 Like

Thank you very much for the hint

@cemzafer Thanks for your answer, this command worked for me but do you know why when I run the df -H inside of my container I got the previous size (203G):

Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/85718809-e3c0-43cf-b899-ba375160df8e  215G   11G  203G   5% /

Hello @SaeedZF

This is due to how BTRFS works sadly, it doesn’t expose quotas through filesystem (unlike ZFS for example). The quota is applied but not visible using command-line utilities such as df.

1 Like

I am having the same issue:

I added 10G to the container but it does not reflect the changes inside:

ubuntu@lxd1:~$ lxc config device set monitoring root size=60G

ubuntu@lxd1:~$ lxc config device show monitoring
root:
path: /
pool: dockers
size: 60GB
type: disk

ubuntu@monitoring:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/disk/by-uuid/9ced87ce-5545-49dc-aabb-655adf1cb6d7 50G 45G 4.6G 91% /

In zfs the container´s filesystem automatically gets the changes.
Do you anyone know how to make container undertand the changes in btrfs?

Thanks,
Pablo.