Disk Quotas
NFS and autofs covered a single filesystem connecting to multiple clients over the network. On a multi-user or shared file server, another problem shows up: a single user or group can fill up an entire partition, taking the service down for everyone else. A disk quota is the mechanism that lets an administrator limit, at the filesystem level, how much space and how many files (inodes) each user or group is allowed to use.
What You Will Learn
By the end of this article you will be able to:
- explain the difference between a user quota and a group quota;
- explain soft limit, hard limit, and grace period, and how they work together;
- enable quotas on an
ext4filesystem through/etc/fstaband activate them withquotacheck/quotaon; - set and monitor quotas with
edquota,setquota, andrepquota; - explain how the quota mechanism on XFS differs from ext4.
Why Quotas Are Needed
On a shared server (for example, home directories under /home, or a file-sharing server), all users share a single filesystem. Without quotas, one user — accidentally or deliberately — can fill up an entire partition, leaving other users unable to write files, with no room left even for system logs or temporary files.
Quotas prevent exactly this: each user or group gets a separate limit, and exceeding it stops with a disk quota exceeded error — affecting only that user's write attempt, not the whole filesystem.
Info
A quota isn't a security mechanism, it's a resource allocation tool. It doesn't stop a user from reading files or executing existing ones — it only limits how much new space they can claim.
The Difference Between User and Group Quotas
Quotas can be set at two independent levels:
- User quota — a limit on a specific user (
UID). For example, useralicecan use at most 10 GiB under/home. - Group quota — a shared limit on a specific group (
GID). Every user in the group has their files counted together against this limit. For example, thedevgroup can use at most 50 GiB in a shared project directory, not per individual member.
Both can be used at once: a user is bound both by their own personal limit and by whichever group limit they belong to — whichever fills up first is the one that applies.
Soft Limit, Hard Limit, and Grace Period
The quota system supports two limit levels:
| Concept | Meaning |
|---|---|
| Soft limit | A warning threshold. Exceeding it isn't immediately blocked, but the user is warned and a grace period starts |
| Hard limit | A strict limit. This value can never be exceeded — a write immediately stops with a Disk quota exceeded error |
| Grace period | The time allowed to operate above the soft limit before it's enforced as strictly as the hard limit (usually measured in days) |
The logic works like this: if a user exceeds the soft limit, the system doesn't block them immediately — they can keep working during the grace period (for example, to finish writing a large file). If usage doesn't drop back below the soft limit before the grace period ends, the system automatically starts enforcing the soft limit as strictly as the hard limit.
This two-stage approach matters in practice: it gives a user some temporary extra room, without letting the problem continue indefinitely.
Enabling Quotas in /etc/fstab (ext4)
Quotas are enabled when a filesystem is mounted, using the usrquota and/or grpquota options. They're added to the corresponding line in /etc/fstab:
usrquota— enables user quotas;grpquota— enables group quotas.
The /etc/fstab syntax and mounting via UUID are covered in depth in fstab.
After the change, remount the filesystem (or reboot the server):
quotacheck: the Initial Calculation
Once quotas are enabled, existing files' usage per owner needs to be calculated for the first time. That's what quotacheck does:
-c— create new quota files (aquota.user,aquota.group);-u— calculate for user quotas;-g— calculate for group quotas.
Warning
quotacheck scans the filesystem and can take time on large partitions. There's a risk of an inaccurate result on a production filesystem with active writes in progress — running it during low-load periods, or with the filesystem read-only, is recommended.
quotaon / quotaoff: Activating Quota Enforcement
Once the calculation files are ready, quota enforcement needs to be activated:
Checking the state:
Disabling it (for example, for maintenance):
quotaoff doesn't delete quota files — it only temporarily stops enforcement.
edquota: Setting Quotas (Interactively)
edquota is an interactive tool for editing a user's or group's soft/hard limits — it opens the system's default text editor ($EDITOR):
The editing window looks roughly like this:
Disk quotas for user alice (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/vg_data/lv_home 512000 10485760 12582912 8000 20000 25000
- the
blockscolumns are measured in kilobytes (soft/hard); - the
inodescolumns limit the number of files — this prevents creating a huge number of tiny files, even if they take up little space.
The equivalent command for a group:
A separate command sets the grace period:
setquota: Setting Quotas (for Scripts)
edquota requires an interactive editor; setquota is more convenient for automation — every value is given in a single command:
Argument order: user soft-block hard-block soft-inode hard-inode filesystem.
setquota is widely used in scripts and configuration management tools (Ansible, and others), since it requires no interactive input.
repquota: Producing a Report
To see current usage and limits for every user or group in a single table:
Sample output:
*** Report for user quotas on device /dev/vg_data/lv_home
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
alice -- 9800000 10485760 12582912 7500 8000 25000
bob +- 12800000 10485760 12582912 6days 9100 8000 25000
The + mark on bob's line and 6days in the grace column mean bob is over the soft limit, with 6 days left before the grace period ends, after which writing is blocked.
Quotas on XFS: pquota/gquota
ext4 quotas run as an extra, separately managed layer on top of the filesystem (via quotacheck, aquota.user files). XFS differs — its quota mechanism is built into the filesystem itself, and no external quotacheck is required.
Mount options are named differently on XFS:
uquota/usrquota— user quota;gquota/grpquota— group quota;pquota/prjquota— project quota, an XFS-specific third dimension: a limit tied to a specific directory (for example,/data/project-a), regardless of user or group.
On XFS, management goes through the xfs_quota command, not edquota/setquota:
Info
Because XFS quotas work at the filesystem level, they generally activate right at mount time, without the separate quotacheck step ext4 needs. This is one reason XFS is often chosen for large production filesystems.
Practical Scenario: Setting a Quota on a Shared File Server
Situation: /home is an ext4 filesystem shared by several users. One user (bob) has been uploading large video files, leaving no room for anyone else.
Step 1. Enable quotas in /etc/fstab.
Step 2. Remount and run the initial calculation.
Step 3. Set a limit for bob: soft 8 GiB, hard 10 GiB.
Step 4. Confirm the result.
Step 5. bob tries writing beyond the limit.
$ dd if=/dev/zero of=/home/bob/bigfile bs=1M count=3000
dd: error writing '/home/bob/bigfile': Disk quota exceeded
Conclusion: the write stopped at the hard limit, while the rest of the filesystem (for other users) stayed protected. It's now possible to talk to bob directly about removing unneeded files or raising the limit — without restarting the whole server.
Common Mistakes
Calling quotaon Without quotacheck First
If the quota files (aquota.user, aquota.group) don't exist, quotaon fails. quotacheck must always run at least once, before quotaon.
Setting the Soft and Hard Limits to the Same Value
If soft and hard are equal, the grace period mechanism has no effect in practice — the user is blocked the instant they hit the limit, with no time for a warning. The soft limit is typically set somewhat below the hard limit.
Trying to Use ext4 Syntax on XFS
edquota/setquota can't fully manage XFS quotas — xfs_quota is required for XFS. Don't mix up filesystem types.
Enabling Only a User Quota and Forgetting the Group Quota
In a shared project directory, with no group-level control, several members of a single group can together fill the space, even if each individual member is under their own user limit.
Exercises
- In a disposable VM, create a separate partition, format it with
ext4, and mount it withusrquota/grpquota. - Set an 100 MiB soft / 150 MiB hard limit for a test user via
setquotaand try exceeding it withdd. - Watch the grace period column in
repquotaoutput: determine how many days after exceeding the soft limit it starts being enforced as a hard limit. - Format the same partition with
xfsand set the same limit again throughxfs_quota, and note the command differences between the two filesystems.
Verification criterion: given a user's repquota line showing a + mark and a grace value, you should be able to explain what will happen if usage isn't reduced before the grace period ends.
Summary
A disk quota limits space and inode count at the user and group level; soft/hard limits and a grace period balance strictness with flexibility. On ext4, quotas are enabled step by step through an /etc/fstab option, quotacheck, and quotaon, and managed through the edquota/setquota/repquota trio. XFS has its own built-in quota mechanism, managed through xfs_quota, with additional support for project-level quotas. A quota limits users, but doesn't show the filesystem's actual current usage — that distinction is covered in Disk Usage.