The quota system allows limiting disk space allocated to a user or group of users. To set it up, you must have a kernel that supports it (compiled with the CONFIG_QUOTA
option) — as is the case with Debian kernels. The quota management software is found in the quota Debian package.
To activate quota in a filesystem, you have to indicate the usrquota
and grpquota
options in /etc/fstab
for the user and group quotas, respectively. Rebooting the computer will then update the quotas in the absence of disk activity (a necessary condition for proper accounting of already used disk space).
edquota user
(或者 edquota -g group
)命令允许在检查目前磁盘空间使用情况时,改变配额限制。
配额系统允许设置四个限制:
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, a block contains 1024 bytes from the same 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.
两种限制(软的和硬的)使用的节点(inode)数限制。每个文件至少需要一个包含存储信息(许可权限,所有者,最后读取时间,等)的节点。因此,它实际上是限制了用户文件的数量。
“软”限制可以被临时超越;当用户超过 warnquota
命令指定的配额,只是给出警告,通常有 cron
唤起该命令。“硬”限制不允许被超出:系统将会拒绝任何超出硬配额的操作。
使用命令 edquota -t
,可以设定超过软限制的“宽限期”时长。宽限期之后,软限制将作为硬限制处理,要将数据写入硬盘,用户必须减少磁盘使用量至配额之内。