Quota inside LXD container


(Brooke Tsui) #1

I want to enable quota inside LXD container so as to limit each user to 10GB storage. I’m using ZFS storage backend. However I got the following error:

root@test:~# quotacheck -avug
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.

How to enable quota inside LXD container?

$ lxc config show test
architecture: x86_64
config:
raw.lxc: lxc.rootfs.options=usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0
security.privileged: “true”
volatile.base_image: 08bbf441bb737097586e9f313b239cecbba96222e58457881b3718c45c17e074
volatile.eth0.hwaddr: 00:16:3e:d3:ab:f7
volatile.idmap.base: “0”
volatile.idmap.next: ‘[]’
volatile.last_state.idmap: ‘[]’
volatile.last_state.power: RUNNING
devices:
root:
path: /
type: disk
ephemeral: false
profiles:

  • default
    stateful: false
    description: “”

root@test:~# cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0

root@test:~# cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION=“Ubuntu 16.04.4 LTS”
NAME=“Ubuntu”
VERSION=“16.04.4 LTS (Xenial Xerus)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=“Ubuntu 16.04.4 LTS”
VERSION_ID=“16.04”
HOME_URL=“http://www.ubuntu.com/
SUPPORT_URL=“http://help.ubuntu.com/
BUG_REPORT_URL=“http://bugs.launchpad.net/ubuntu/
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial


(Stéphane Graber) #2

Hmm, does ZFS even implement standard Linux user quotas?

I know it can do per-user/group quotas through zfs set but that’s a completely different interface.


(Brooke Tsui) #3

I can confirm the ZFS backend supports user/group quotas because I have another container on the same host with the following fstab and the quotacheck works as shown below.

root@test:~# cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0
/dev/zd0 /home2 ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv1 0 0

root@test:~# mount -a
root@test:~# quotacheck -avugmc
quotacheck: Scanning /dev/zd0 [/home2] done
quotacheck: Checked 3 directories and 4 files


(Stéphane Graber) #4

That second container isn’t showing quotas on ZFS but on ext4 though, it shows that /home2 has quotas applied to it and that this comes from a ZFS volume (not a dataset) which is formatted as ext4.


(Brooke Tsui) #5

Thank you for pointing this out!

Now I have a now question. Is the 1st entry “LABEL=cloudimg-rootfs / ext4 defaults 0 0” actually ignored? It was created by LXD by default when the container was created. The root is actually a bind-mount from the LXD zpool and the root is “in fact NOT” ext4 as what is shown in the fstab.