I have a fresh Debian 12 system and I'm trying to turn on and enforce EXT4 filesystem quota. I read a lot of
man
and some other sources, for example this one from Red Hat: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_file_systems/limiting-storage-space-usage-on-ext4-with-quotas_managing-file-systems
And I cannot make it work and after several hours of trying I'm confused. I do not know, if there is a sane way to do this or am I missing something. Let's try it on a loop file.
vagrant@bookworm:~$ sudo dd status=progress if=/dev/zero of=ext4_fs bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 0.595179 s, 1.8 GB/s
vagrant@bookworm:~$ sudo mkfs.ext4 ext4_fs
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 256000 4k blocks and 64000 inodes
Filesystem UUID: 2d5eedba-eada-4b9f-ba88-e182b3ff24fa
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
vagrant@bookworm:~$ sudo tune2fs -O quota ext4_fs
tune2fs 1.47.0 (5-Feb-2023)
vagrant@bookworm:~$ mkdir mountpoint
vagrant@bookworm:~$ sudo mount ext4_fs mountpoint/
vagrant@bookworm:~$ ls mountpoint/
lost+found
vagrant@bookworm:~$ sudo quotaon -v -p mountpoint/
group quota on /home/vagrant/mountpoint (/dev/loop0) is on (accounting)
user quota on /home/vagrant/mountpoint (/dev/loop0) is on (accounting)
project quota on /home/vagrant/mountpoint (/dev/loop0) is off
So far so good. Now, are files aquota.user
or aquota.group
required? If so, they should be created automatically using the quotacheck
command:
vagrant@bookworm:~$ sudo quotacheck -cugm mountpoint/
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
Weird. When I remount the system ro
, the command starts, but obviously cannot work properly and write those files:
vagrant@bookworm:~$ sudo quotacheck -cugm mountpoint/
quotacheck: Cannot create new quotafile /home/vagrant/mountpoint/aquota.user.new: Read-only file system
quotacheck: Cannot initialize IO on new quotafile: Read-only file system
When I try to enforcing
the quota, I add usrquota
to fstab
and reboot.
/home/vagrant/ext4_fs /home/vagrant/mountpoint ext4 rw,nodev,nosuid,defaults,usrquota 0 0
Quotas are enforced, but aquota.user
file is missing, I still cannot run quotacheck
, and now systemd
is added to the mix, with failed quotaon.service
:
vagrant@bookworm:~$ sudo systemctl status quotaon.service
× quotaon.service - Enable File System Quotas
Loaded: loaded (/lib/systemd/system/quotaon.service; static)
Active: failed (Result: exit-code) since Sun 2023-09-24 15:18:07 UTC; 8min ago
Docs: man:quotaon(8)
Process: 359 ExecStart=/sbin/quotaon -aug (code=exited, status=1/FAILURE)
Main PID: 359 (code=exited, status=1/FAILURE)
CPU: 1ms
Sep 24 15:18:07 bookworm systemd: Starting quotaon.service - Enable File System Quotas...
Sep 24 15:18:07 bookworm quotaon: quotaon: using . on /dev/loop0 [/home/vagrant/mountpoint]: File exists
Sep 24 15:18:07 bookworm systemd: quotaon.service: Main process exited, code=exited, status=1/FAILURE
Sep 24 15:18:07 bookworm systemd: quotaon.service: Failed with result 'exit-code'.
Sep 24 15:18:07 bookworm systemd: Failed to start quotaon.service - Enable File System Quotas.
And there is also:
vagrant@bookworm:~$ sudo systemctl status systemd-quotacheck.service
● systemd-quotacheck.service - File System Quota Check
Loaded: loaded (/lib/systemd/system/systemd-quotacheck.service; static)
Active: active (exited) since Sun 2023-09-24 15:18:07 UTC; 12min ago
Docs: man:systemd-quotacheck.service(8)
Process: 354 ExecStart=/lib/systemd/systemd-quotacheck (code=exited, status=0/SUCCESS)
Main PID: 354 (code=exited, status=0/SUCCESS)
CPU: 3ms
Sep 24 15:18:07 bookworm systemd: Starting systemd-quotacheck.service - File System Quota Check...
Sep 24 15:18:07 bookworm systemd: Finished systemd-quotacheck.service - File System Quota Check.
What is the sane way in 2023 to configure disk quotas?
Kind regards.
Asked by Kamil
(1501 rep)
Sep 24, 2023, 03:36 PM
Last activity: Sep 25, 2023, 05:52 AM
Last activity: Sep 25, 2023, 05:52 AM