0

I want to enable quota inside LXD container so as to limit each user to 10GB storage. 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?

Below is my host configuration:

$ 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: ""

$ 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

Below is my container configuration:

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
2
  • " or filesystem not mounted with quota option." Is that not enough to go on for you? – Rinzwind Jun 2 '18 at 18:15
  • I tried adding usrquota,grpquota as below but still got the same error. root@test:~# cat /etc/fstab LABEL=cloudimg-rootfs / ext4 defaults,usrquota,grpquota 0 0 – Brooke Tsui Jun 3 '18 at 8:47
0

You should select zfs or btrfs as storage backend in the initialization of LXD to support disk quota. Other storage backends don't support quota.

1
  • I was using ZFS as show below. $ lxc info config: storage.zfs_pool_name: lxd api_extensions: - id_map - id_map_base - resource_limits api_status: stable api_version: "1.0" auth: trusted auth_methods: [] public: false environment: addresses: [] architectures: - x86_64 - i686 driver: lxc driver_version: 2.0.8 kernel: Linux kernel_architecture: x86_64 kernel_version: 4.4.0-130-generic server: lxd server_pid: 2661 server_version: 2.0.11 storage: zfs storage_version: "5" – Brooke Tsui Jul 4 '18 at 14:59
0

I have been looking all around having myself the same issue. Here is what I ended with.

The filesystem supported features are in the doc

So, the only way to have quotas support from inside the container is using BTRFS, which I personally don't wanna to use.

On ZFS you can only set quota from the host, not from the guest, because ZFS support in LXD doesn't check the "Storage driver usable inside a container" box. There an issue about it. Regarding users and groups quotas set from the host. I haven't tested and wonder how it is supported and if it may need UID/GID mapping from guest to host. No sure about that though.

On ZFS, ZVOL do exist and can be formatted as ext4, they are seen as a standard block device from the guest side, and thus can be used for standard linux quotas. But those cannot be used for rootfs, see the issue on GitHub. You can still mount it in areas that have users data to check against quotas (eg. /home, /var).

Then there is libvirt virtualization over ZFS ZVOLs, which is slower but just works as expected regarding linux quotas.

As an advice, always make your ZVOLs at minimum needed size as it is much easier to expand than to shrink, the later requiring downtime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.