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.
The quota system allows you to set four limits:
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.
A “soft” limit can be temporarily exceeded; the user will simply be warned that they are exceeding the quota by the warnquota
command, which is usually invoked by cron
. A “hard” limit can never be exceeded: the system will refuse any operation that will cause a hard quota to be exceeded.
With the edquota -t
command, you can define a maximum authorized “grace period” within which a soft limit may be exceeded. After this period, the soft limit will be treated like a hard limit, and the user will have to reduce their disk space usage to within this limit in order to be able to write anything to the hard drive.