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).
The edquota user
(or edquota -g group
) command allows you to change the limits while examining current disk space usage.
配额系统允许设置四个限制:
两种限制(称为“软的”和“硬的”)使用消耗的块数表示。如果文件系统使用1K的块创建,相同文件的每个块包含1024字节。不饱和的块会减少磁盘空间。100个块的配额,理论上允许存储102400字节,然而,它们有可能被100个每个包含500字节的文件填充,总数仅仅是50000字节。
两种限制(软的和硬的)使用的节点(inode)数限制。每个文件至少需要一个包含存储信息(许可权限,所有者,最后读取时间,等)的节点。因此,它实际上是限制了用户文件的数量。
“软”限制可以被临时超越;当用户超过 warnquota
命令指定的配额,只是给出警告,通常有 cron
唤起该命令。“硬”限制不允许被超出:系统将会拒绝任何超出硬配额的操作。
使用命令 edquota -t
,可以设定超过软限制的“宽限期”时长。宽限期之后,软限制将作为硬限制处理,要将数据写入硬盘,用户必须减少磁盘使用量至配额之内。