Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Set up disk quotas

By updated

Improve this page

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 quota and the usrquota and grpquota mount options;
  • Manage XFS quotas with xfs_quota, without quotacheck;
  • Set per-user limits with edquota or setquota;
  • Monitor usage with repquota and 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 systemMechanismTools
ext4Internal accounting (tune2fs -O quota), enforced by the usrquota/grpquota optionstune2fs, edquota, setquota, repquota (quotacheck/quotaon for the old method)
XFSQuotas enabled at mount time via uquota/gquota/pquota, internal accountingxfs_quota only
BtrfsQgroups per subvolume, no user quotasbtrfs qgroup
ZFSProperties per dataset or per userzfs 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:

Terminal window
grep CONFIG_QUOTA= /boot/config-$(uname -r)

The output must show CONFIG_QUOTA=y. Then install the user-space tools:

Terminal window
sudo apt install quota

On 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:

Terminal window
sudo umount /home
sudo tune2fs -O quota /dev/sdb1

Then 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 2
Terminal window
sudo systemctl daemon-reload
sudo mount /home
sudo quotaon -p /home
group quota on /home (/dev/sdb1) is on
user quota on /home (/dev/sdb1) is on
project quota on /home (/dev/sdb1) is off

Quotas 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 using
external quota files. Please switch your filesystem to use ext4 quota feature
as 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:

Terminal window
sudo systemctl daemon-reload
sudo mount -o remount /home
findmnt /home
sudo quotacheck -cugm /home
sudo quotaon /home

The 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:

Terminal window
sudo edquota alice

The 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:

Terminal window
sudo setquota -u alice 5242880 6291456 0 0 /home

Here 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:

Terminal window
sudo edquota -t

Finally, 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):

Terminal window
sudo repquota -s /home
quota -us alice

Quotas 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 0

Beware, 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:

Terminal window
sudo umount /data
sudo mount /data

For 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:

Terminal window
sudo xfs_quota -x -c 'state' /data

The 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:

Terminal window
sudo xfs_quota -x -c 'limit -u bsoft=5g bhard=6g alice' /data

Show a report of the whole partition (-h for readable sizes):

Terminal window
sudo xfs_quota -x -c 'report -h' /data

The 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:

Terminal window
sudo btrfs quota enable /mnt

Management

Each subvolume gets a qgroup. List them, then set a limit on a subvolume:

Terminal window
sudo btrfs qgroup show /mnt
sudo btrfs qgroup limit 5G /mnt/sousvolume

Keep 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):

Terminal window
sudo apt install zfsutils-linux

Management

Limit the total size of a dataset:

Terminal window
sudo zfs set quota=10G tank/home

ZFS can also limit a specific user inside a dataset, with the userquota@ property:

Terminal window
sudo zfs set userquota@alice=5G tank/home

Check 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 2

Then the same sequence as for an ext4 partition, with tune2fs targeting the logical volume:

Terminal window
sudo umount /home
sudo tune2fs -O quota /dev/mapper/vg_data-lv_home
sudo mount /home

Special 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):

Terminal window
sudo quotacheck -avugm

On 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 deprecated aquota.* files.
  • On XFS, always use xfs_quota and 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:

Terminal window
0 3 * * * /usr/sbin/repquota -a | mail -s "Rapport quotas quotidien" root

You 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.

SymptomLikely causeFix
quotacheck says it cannot find a file system to checkusrquota/grpquota options missing from /etc/fstab, or partition not remounted since they were addedCheck with findmnt /home, fix /etc/fstab, mount again
XFS quotas stay inactive after mount -o remountXFS only applies uquota/gquota at the initial mountUnmount then mount the partition again; for the root, rootflags= and a reboot
Disk quota exceeded while space seems availableInode limit reached, or grace period of the soft limit expiredquota -us alice to see blocks and inodes; adjust with edquota
repquota shows figures inconsistent with duOut-of-sync accounting (sudden stop, snapshot restore) on ext4External files: sudo quotacheck -avugm then sudo quotaon; internal feature: e2fsck on the unmounted system
quotacheck or quotaon warns: external quota files on ext4 are deprecatedOld method with aquota.* filesMigrate: quotaoff, unmount, tune2fs -O quota, mount again
quotacheck run on an XFS partitionConfusion between the two mechanisms: XFS does not use quotacheckUse 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 quota on the unmounted system, then the usrquota/grpquota options in /etc/fstab; quotacheck's aquota.* files are deprecated. Limits are set with edquota or setquota.
  • On XFS: uquota/gquota options and management via xfs_quota; no quotacheck, and activation requires a full unmount, not a remount.
  • Btrfs limits subvolumes (qgroups), not users; ZFS does both with the quota and userquota@ properties.
  • LVM manages no quotas: they are configured on the file system placed on top of the logical volume.
  • repquota -s for the administrator view, quota -us for 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

6 questions
6 min
70% to pass

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

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn