配额系统可以限制用户与群组可用的磁盘空间。设置时,必须内核支持 (以 CONFIG_QUOTA
选项编译) — 使用 Debian 内核时。配额管理软件在 quota Debian 软件包内。
在文件系统内启用配额时,必须在 /etc/fstab
中指明 usrquota
与 grpquota
选项,分别供用户与群组使用。重新启动电脑后,就能在未使用的磁盘空间中更新配额 (必须如此,才能重新计算已使用的磁盘空间)。
edquota user
(或 edquota -g group
) 命令允许在仍有磁盘空间的前提下,改变配额。
配额系统允许设置4个限制:
two limits (called “soft” and “hard”) refer to the number of blocks consumed. If the filesystem was created with a block-size of 1 kibibyte, the 1024 available bytes of each block can only be assigned to one file. Unsaturated blocks thus induce losses of disk space. A quota of 100 blocks, which theoretically allows storage of 102,400 bytes, will, however, be saturated with just 100 files of 500 bytes each, only representing 50,000 bytes in total.
two limits (“soft” and “hard”) refer to the number of inodes used. Each file occupies at least one inode to store information about it (permissions, owner, timestamp of last access, etc.). It is thus a limit on the number of user files.
“软”限制可以被临时超越;当用户超过 warnquota
命令指定的配额,只是给出警告,通常由 cron
唤起该命令。“硬”限制不允许被超出:系统将会拒绝任何超出硬配额的操作。
使用命令 edquota -t
,可以设定超过软限制的“宽限期”时长。宽限期之后,软限制将作为硬限制处理,要将数据写入硬盘,用户必须减少磁盘使用量至配额之内。