Disk quotas limit the space or the number of files a user or a group can
consume on a file system, and keep a single account from filling up the
server. This guide shows how to enable and manage them on ext4 (quota
feature, usrquota/grpquota options, edquota) and on XFS
(xfs_quota), two different mechanisms not to mix up, then covers Btrfs,
ZFS and the LVM case. It is aimed at administrators of multi-user
servers: file servers, shared hosting, shared build machines. By the end, you
will know how to set soft and hard limits, tune the grace period and
monitor usage with repquota.
What you will learn
- Tell soft from hard limits, block quotas from inode quotas;
- Enable quotas on ext4 with
tune2fs -O quotaand theusrquotaandgrpquotamount options; - Manage XFS quotas with
xfs_quota, withoutquotacheck; - Set per-user limits with
edquotaorsetquota; - Monitor usage with
repquotaand diagnose blocked writes.
Understand disk quotas on Linux
A disk quota is a limit set on the amount of disk space or on the number of files a user or a group can use on a Linux system. The goal is to prevent the disk from filling up through excessive use and to guarantee fair sharing of resources.
Why quotas are useful
In multi-user environments, quotas are essential to:
- Avoid resource abuse by limiting individual space.
- Prevent system outages caused by a full disk.
- Plan and size resources efficiently according to real needs.
Quotas are especially used on file servers, shared hosting and cloud infrastructures, wherever several accounts share the same volume.
Types of quotas
Linux mainly offers two types of quotas:
- Block quota: limits the amount of disk space (in KB, MB, GB) a user or a group can consume.
- Inode quota: limits the total number of files a user or group can create.
Each type of quota can be set for an individual user or for a group of users.
Soft limits and hard limits
- Soft limit: a threshold the user can exceed temporarily. The system allows going over it during a configurable grace period (7 days by default).
- Hard limit: an absolute value never to exceed. As soon as this limit is reached, no further write is allowed.
Example: a user has a soft limit of 5 GB and a hard limit of 6 GB. They can use up to 6 GB, but must go back under 5 GB before the end of the grace period, otherwise the soft limit becomes blocking in turn.
One mechanism per file system
Quota management depends on the file system: the commands are not interchangeable, and it is the most frequent source of error on this topic. This table sums up who does what before going into detail.
| File system | Mechanism | Tools |
|---|---|---|
| ext4 | Internal accounting (tune2fs -O quota), enforced by the usrquota/grpquota options | tune2fs, edquota, setquota, repquota (quotacheck/quotaon for the old method) |
| XFS | Quotas enabled at mount time via uquota/gquota/pquota, internal accounting | xfs_quota only |
| Btrfs | Qgroups per subvolume, no user quotas | btrfs qgroup |
| ZFS | Properties per dataset or per user | zfs set quota / userquota@ |
Quotas on ext4
The ext4 file system is the most common on Linux distributions. It supports quotas in two ways: internal accounting, the current method, and old external files, deprecated but still very widespread.
Installation
Quota support is compiled into the kernel of every common distribution. You can check it:
grep CONFIG_QUOTA= /boot/config-$(uname -r)The output must show CONFIG_QUOTA=y. Then install the user-space tools:
sudo apt install quotaOn RHEL and derivatives, the package is also called quota (sudo dnf install quota).
Activation: ext4's quota feature
ext4 can keep quota accounting internally, in hidden inodes, like XFS: it
is the current method. It is set once, on the unmounted file system,
with tune2fs:
sudo umount /homesudo tune2fs -O quota /dev/sdb1Then add the usrquota (user quotas) and grpquota (group quotas)
options on the partition's line in /etc/fstab, the file that describes
persistent mounts, then mount again:
UUID=xxx /home ext4 defaults,usrquota,grpquota 0 2sudo systemctl daemon-reloadsudo mount /homesudo quotaon -p /homegroup quota on /home (/dev/sdb1) is onuser quota on /home (/dev/sdb1) is onproject quota on /home (/dev/sdb1) is offQuotas are active from the mount: no quotacheck nor quotaon to run, and
no file at the root of the partition. Measured on AlmaLinux 10 (e2fsprogs
1.47.1, quota 4.09): with a hard limit of 2 MiB, a 3 MiB dd stops on
Disk quota exceeded. For the root partition, which cannot be
unmounted, the tune2fs is done from a rescue system.
The old method: external aquota files
Many guides, and systems installed long ago, use external accounting files
(aquota.user, aquota.group) created by quotacheck. The method still
works, but quotacheck and quotaon themselves report that it is
deprecated on ext4:
quotacheck: Your kernel probably supports ext4 quota feature but you are usingexternal quota files. Please switch your filesystem to use ext4 quota featureas external quota files on ext4 are deprecated.If you come across it, here is the sequence: usrquota,grpquota options in
/etc/fstab, a remount (which is enough on ext4), then file creation and
activation:
sudo systemctl daemon-reloadsudo mount -o remount /homefindmnt /homesudo quotacheck -cugm /homesudo quotaon /homeThe OPTIONS column of findmnt must contain usrquota and grpquota.
The quotacheck options: -c creates the quota files, -u handles users,
-g groups, -m avoids remounting the partition read-only during the
scan. The kernel then keeps accounting up to date, and quotacheck is only
used to resynchronise after an incident. To migrate to the internal
feature: quotaoff, unmount, tune2fs -O quota, mount again.
Set and view limits
The edquota command opens a user's limits in your text editor:
sudo edquota aliceThe file shown contains, for each file system, the current usage then four
columns to fill in: soft and hard limits in 1 KB blocks, then soft and
hard limits in inodes. The value 0 means "no limit". To script the same
operation without an editor, use setquota:
sudo setquota -u alice 5242880 6291456 0 0 /homeHere 5242880 blocks of 1 KB = 5 GB as the soft limit, 6291456 = 6 GB as the hard limit, and no inode limit. The grace period is set globally per file system:
sudo edquota -tFinally, two viewing commands: repquota gives the administrator view
of the whole partition, and quota the view of one account (the -s
option shows readable sizes):
sudo repquota -s /homequota -us aliceQuotas on XFS
The XFS file system, RHEL's default choice,
handles quotas in a radically different way from ext4: there is no
quotacheck nor quotaon to run. Accounting is kept internally by the file
system and quotas are enabled at mount time.
Activation
Add the uquota (users) and gquota (groups) options in
/etc/fstab; XFS also offers pquota for project quotas (directory
trees):
UUID=xxx /data xfs defaults,uquota,gquota 0 0Beware, classic trap: unlike ext4, these options are not taken into
account by a simple remount. A mount -o remount /data returns 0 with no
message and changes nothing (findmnt still shows noquota), you must
unmount then mount the partition again:
sudo umount /datasudo mount /dataFor the root file system, which cannot be unmounted: pass the option to
the kernel via rootflags=uquota in the GRUB configuration, then reboot.
Then check the quota state:
sudo xfs_quota -x -c 'state' /dataThe output must show Accounting: ON and Enforcement: ON for the enabled
quota types.
Management
All management goes through xfs_quota in expert mode (-x). Set
limits for a user, with the k, m, g or t suffixes:
sudo xfs_quota -x -c 'limit -u bsoft=5g bhard=6g alice' /dataShow a report of the whole partition (-h for readable sizes):
sudo xfs_quota -x -c 'report -h' /dataThe edquota and repquota commands of the quota package can also talk
to XFS, but you might as well get used to the native tool: it is the one
that exposes every feature, notably project quotas.
Quotas on Btrfs
The Btrfs file system approaches the topic from a completely different angle: it has no per-user or per-group quotas. Its qgroups limit the space consumed by subvolumes. If your need is "limit user alice to 5 GB", Btrfs cannot do it directly; if it is "limit each project's subvolume", qgroups fit well.
Activation
Support is native in the kernel, with no extra tool. Enable quota tracking on the file system:
sudo btrfs quota enable /mntManagement
Each subvolume gets a qgroup. List them, then set a limit on a subvolume:
sudo btrfs qgroup show /mntsudo btrfs qgroup limit 5G /mnt/sousvolumeKeep in mind that enabling qgroups has a performance cost, especially with many snapshots: only enable them if you need them.
Quotas on ZFS
With ZFS, quotas are not a mount option but a simple dataset property, changeable live. It is the most flexible approach of the four.
Installation
Install ZFS and its tools (zfsutils-linux on Debian/Ubuntu, where the kernel
module is provided via DKMS):
sudo apt install zfsutils-linuxManagement
Limit the total size of a dataset:
sudo zfs set quota=10G tank/homeZFS can also limit a specific user inside a dataset, with the
userquota@ property:
sudo zfs set userquota@alice=5G tank/homeCheck the space used per dataset with zfs list, and consumption per user
with zfs userspace tank/home.
What about LVM?
LVM (Logical Volume Manager) does not act at the same level: it is a volume management layer under the file system, not a file system. Quotas are therefore configured on the file system placed on top of the logical volume (ext4, XFS...), exactly as on a classic partition.
Example of activation on an ext4 LVM volume, in /etc/fstab:
/dev/mapper/vg_data-lv_home /home ext4 defaults,usrquota,grpquota 0 2Then the same sequence as for an ext4 partition, with tune2fs targeting the
logical volume:
sudo umount /homesudo tune2fs -O quota /dev/mapper/vg_data-lv_homesudo mount /homeSpecial case: LVM snapshots
Files and quota accounting live inside the file system: an
LVM snapshot therefore carries
them along with the rest of the data. The point of attention comes after a
rollback (lvconvert --merge): the restored accounting may no longer
reflect the activity that took place between the snapshot and the restore. On
ext4 with old external files, resynchronise it (with the internal feature, it
is e2fsck that checks the accounting):
sudo quotacheck -avugmOn XFS, nothing to do: the file system checks the consistency of its accounting at mount time and rebuilds it if needed.
Good practices for disk quota management
Setting up disk quotas is an essential step to ensure the stability and balance of storage use. Here are the good practices to follow for efficient and lasting management.
Plan space usage
Before applying quotas, assess:
- The number of users and groups.
- The average space needed per user.
- Specific needs (e.g. technical users vs office users).
Tip: keep a margin for system operations and activity peaks, and prefer soft limits slightly below the hard limits to give users time to clean up.
Choose the method suited to the file system
- On ext4, enable the internal feature (
tune2fs -O quota, on the unmounted system) rather than the deprecatedaquota.*files. - On XFS, always use
xfs_quotaand remember that activation requires a real unmount, not a remount. - On Btrfs, enable qgroups (
btrfs quota enable) knowing that they limit subvolumes, not users. - On LVM, apply quotas on the mounted file system, not on the logical volumes themselves.
Monitor usage regularly
A quota that blocks a user without warning generates tickets; a regular
report lets you anticipate. Schedule a periodic check via cron to
detect overruns:
0 3 * * * /usr/sbin/repquota -a | mail -s "Rapport quotas quotidien" rootYou can also feed these metrics into your monitoring tool to trigger alerts before the hard limit is reached.
Adapt quotas as needs evolve
- Adjust quota limits every 6 to 12 months according to real usage.
- Delete or archive inactive accounts to free disk space.
- Take into account new projects or services that consume a lot of storage.
Document the quota policy
- Inform users clearly of their space limits and of the actions taken when they are exceeded.
- Document the alert procedure and the procedure to request a quota increase.
Troubleshooting
Most quota problems come from missing mount options, from the ext4/XFS confusion or from out-of-sync accounting. This table groups the most frequent symptoms.
| Symptom | Likely cause | Fix |
|---|---|---|
quotacheck says it cannot find a file system to check | usrquota/grpquota options missing from /etc/fstab, or partition not remounted since they were added | Check with findmnt /home, fix /etc/fstab, mount again |
XFS quotas stay inactive after mount -o remount | XFS only applies uquota/gquota at the initial mount | Unmount then mount the partition again; for the root, rootflags= and a reboot |
Disk quota exceeded while space seems available | Inode limit reached, or grace period of the soft limit expired | quota -us alice to see blocks and inodes; adjust with edquota |
repquota shows figures inconsistent with du | Out-of-sync accounting (sudden stop, snapshot restore) on ext4 | External files: sudo quotacheck -avugm then sudo quotaon; internal feature: e2fsck on the unmounted system |
quotacheck or quotaon warns: external quota files on ext4 are deprecated | Old method with aquota.* files | Migrate: quotaoff, unmount, tune2fs -O quota, mount again |
quotacheck run on an XFS partition | Confusion between the two mechanisms: XFS does not use quotacheck | Use xfs_quota -x -c 'state' and -c 'report' instead |
Put it into practice
Get hands-on on a VM: enable XFS quotas on a file system and enforce a limit on a user, until you see the write refused when it is exceeded.
Key points
- A quota limits blocks (space) or inodes (number of files); the soft limit tolerates going over during the grace period, the hard limit blocks immediately.
- On ext4:
tune2fs -O quotaon the unmounted system, then theusrquota/grpquotaoptions in/etc/fstab;quotacheck'saquota.*files are deprecated. Limits are set withedquotaorsetquota. - On XFS:
uquota/gquotaoptions and management viaxfs_quota; noquotacheck, and activation requires a full unmount, not a remount. - Btrfs limits subvolumes (qgroups), not users; ZFS does both with
the
quotaanduserquota@properties. - LVM manages no quotas: they are configured on the file system placed on top of the logical volume.
repquota -sfor the administrator view,quota -usfor one account's view: monitor before the hard limit blocks users.
Knowledge check
Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Discover and administer Btrfs on Linux
A new full quiz with random questions
Work again only on the questions you missed