我有一个新的 Debian 12 系统,我正在尝试打开并强制执行 EXT4 文件系统配额。我阅读了很多资料man
和其他一些资料,例如来自 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
我无法让它发挥作用,经过几个小时的尝试我很困惑。我不知道是否有一种明智的方法可以做到这一点,或者我是否遗漏了一些东西。让我们在循环文件上尝试一下。
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
到目前为止,一切都很好。现在,文件aquota.user
还是aquota.group
必需的?如果是这样,它们应该使用以下命令自动创建quotacheck
:
vagrant@bookworm:~$ sudo quotacheck -cugm mountpoint/
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
诡异的。当我重新安装系统时ro
,命令启动,但显然无法正常工作并写入这些文件:
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
当我尝试enforcing
配额时,我添加usrquota
并fstab
重新启动。
/home/vagrant/ext4_fs /home/vagrant/mountpoint ext4 rw,nodev,nosuid,defaults,usrquota 0 0
配额已强制执行,但aquota.user
文件丢失,我仍然无法运行quotacheck
,现在systemd
添加到混合中,失败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[1]: Starting quotaon.service - Enable File System Quotas...
Sep 24 15:18:07 bookworm quotaon[359]: quotaon: using . on /dev/loop0 [/home/vagrant/mountpoint]: File exists
Sep 24 15:18:07 bookworm systemd[1]: quotaon.service: Main process exited, code=exited, status=1/FAILURE
Sep 24 15:18:07 bookworm systemd[1]: quotaon.service: Failed with result 'exit-code'.
Sep 24 15:18:07 bookworm systemd[1]: Failed to start quotaon.service - Enable File System Quotas.
并且还有:
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[1]: Starting systemd-quotacheck.service - File System Quota Check...
Sep 24 15:18:07 bookworm systemd[1]: Finished systemd-quotacheck.service - File System Quota Check.
2023 年配置磁盘配额的明智方法是什么?
亲切的问候。
答案1
您不需要 ext4 的配额文件,因为配额是通过 ext4 事务在内部自动处理的,因此配额文件不应该与每个用户/组/项目拥有的实际文件不同步。如果出现这种情况,e2fsck 将修复它们。