Linux online course

Linux Disk Quotas: Limiting User and Group Disk Usage

Learn how Linux disk quotas limit user and group disk space and file counts, including soft and hard limits, grace periods, ext4 and XFS setup, commands, and troubleshooting.

A disk quota is a filesystem policy that limits storage resources available to a user or group. Quotas help administrators allocate space predictably on multi-user systems such as servers, shell hosts, mail systems, and shared project storage.

This lesson assumes familiarity with Linux administration, users and groups, filesystems, mount points, ownership, permissions, sudo, and safe editing of /etc/fstab.

Why disk quotas are useful

Without quotas, one account can consume most or all available space. A user might accidentally create a large backup, a runaway application might continuously write logs, or a project might produce millions of files. The result can affect unrelated users and system services.

  • Other users may be unable to create or expand files.
  • Databases, mail services, and logging services may stop working.
  • The operating system may have insufficient space for temporary files or updates.
  • Administrators lose a predictable way to allocate shared storage.

Quotas are enforced per filesystem. A limit configured for /home does not automatically apply to a separate filesystem mounted at /srv or /var. Before configuring quotas, identify the filesystem and mount point containing the data you want to control.

User quotas and group quotas

A user quota applies to an individual Unix user account. It limits resources attributed to that user across the target filesystem.

A group quota applies to a Unix group. It is useful for a shared project allocation: members of the group can collectively consume the group's allowance. User and group quotas can both exist, so an operation may be constrained by either applicable limit.

Quota limit types

Each quota measurement can have two thresholds:

  • Soft limit: a warning threshold that may be exceeded temporarily.
  • Hard limit: an absolute maximum. New allocation beyond it is denied.

When usage rises above a soft limit, the filesystem starts a grace period. The user can normally continue allocating resources during that interval, subject to the hard limit. If the grace period expires while usage is still above the soft limit, the soft limit is treated like an enforced limit: further allocation is denied until usage falls below the soft limit or an administrator changes the policy.

Reaching a hard limit has an immediate effect. A write that needs additional blocks, or an operation that needs another inode, can fail even if the underlying filesystem still has free capacity.

ConditionSoft limit statusHard limit statusGrace period statusExpected result
Usage below the soft limitNot exceededNot reachedNot runningNormal allocation is allowed.
Usage above the soft limit during the grace periodExceededNot reachedActiveWarnings are reported and allocation can continue until the hard limit or grace expiration.
Usage above the soft limit after grace expirationExceededMay not be reachedExpiredFurther allocation is denied until usage is reduced below the soft limit or the limit is changed.
Usage at or above the hard limitMay or may not be exceededReachedNot relevant to the immediate cutoffAdditional allocation is denied immediately.

Block quotas and inode quotas

A block quota, also called a usage quota, limits disk space consumption. Reports commonly display this value in filesystem blocks or human-readable units such as KiB, MiB, GiB, or TiB.

An inode quota limits the number of inodes a user or group may own. An inode is a filesystem data structure representing a file, directory, or another filesystem object. Every file requires an inode, regardless of how small its contents are.

Consequently, many small files can exhaust an inode quota while substantial disk capacity remains. Conversely, one large file can exhaust a block quota while the account still has unused inodes. Block and inode quotas are independent measurements, and both can have soft and hard limits.

Quota typeWhat it limitsTypical failure patternBest use case
Block or usage quotaDisk space consumed by file data and filesystem allocation.Large writes or file expansion fail even though file creation may still be possible.Preventing one account or project from consuming too much storage capacity.
Inode or file quotaThe number of files and other filesystem objects owned by the subject.Creating a new file or directory fails while df still shows free space.Controlling mail spools, caches, temporary files, and workloads that create many small files.

How quota enforcement behaves

Consider a user with a 3 GiB soft block limit and a 5 GiB hard block limit:

  1. Below 3 GiB, writes proceed normally.
  2. When usage crosses 3 GiB, the grace-period countdown begins and quota-aware operations can produce warnings.
  3. During the grace period, the user can continue writing while usage remains below 5 GiB.
  4. At 5 GiB, any operation requiring additional blocks is rejected immediately.
  5. If the grace period expires while usage remains above 3 GiB, additional allocation is rejected even if usage has not reached 5 GiB.
  6. After files are removed or moved and usage falls below 3 GiB, normal allocation can resume, subject to the limits.

The same pattern applies to inode limits. Crossing an inode soft limit starts a grace period, reaching an inode hard limit prevents creation of more objects, and remaining above the inode soft limit after grace expiration prevents further inode allocation.

Preparing a filesystem for quotas

1. Identify the filesystem and scope

Choose the mount point to control, then identify whether the policy applies to users, groups, or both. Check the path and its filesystem before changing configuration.

findmnt /home
df -T /home
findmnt -no SOURCE,FSTYPE,TARGET,OPTIONS /home

The filesystem type matters because quota setup differs between ext-family filesystems and XFS. A quota configured for one mount point does not cover a different filesystem mounted beneath it.

2. Install quota-management utilities

On Debian and Ubuntu systems, install the common quota utilities as follows:

sudo apt update
sudo apt install quota

On Red Hat family systems:

sudo dnf install quota

Package names and available commands can vary by distribution and release. Confirm the installed documentation before using a command in production.

3. Enable quotas on an ext-family filesystem

For a traditional ext2, ext3, or ext4 workflow, add the appropriate mount options to the persistent filesystem entry. The following example enables both user and group quotas for /home:

# /etc/fstab
/dev/sdb1  /home  ext4  defaults,usrquota,grpquota  0  2

Use the actual device or UUID, mount point, and filesystem type on the system. Back up and carefully validate /etc/fstab before rebooting. After changing a persistent mount configuration, remount the filesystem or restart the system:

sudo mount -o remount /home
findmnt -no TARGET,OPTIONS /home

The second command should show the quota options supported by the chosen setup. Modern ext4 systems may use filesystem-native quota features rather than quota files. Follow the distribution and filesystem documentation when selecting the supported method.

4. Initialize accounting

Quota accounting means tracking resource consumption by users and groups. With the ext-family quota-file workflow, initialize or refresh accounting with:

sudo quotacheck -cugm /home
  • -c requests creation of quota data when needed.
  • -u checks user accounting.
  • -g checks group accounting.
  • -m permits checking a mounted filesystem.

A scan can consume significant I/O and CPU, especially on a large active filesystem. Schedule it carefully and follow local guidance about whether users should be logged out or whether the filesystem should be quiescent.

5. Enable enforcement

Quota enforcement actively prevents allocations that violate applicable limits. Enable user and group enforcement with:

sudo quotaon -vug /home

To temporarily disable enforcement:

sudo quotaoff -vug /home

Accounting and enforcement are related but distinct. The system can track usage without actively rejecting allocations, depending on the filesystem and configuration.

Managing user and group quotas

Interactive editing with edquota

edquota opens a quota record in an editor. Edit a user quota with:

sudo edquota -u alice

Edit a group quota with:

sudo edquota -g developers

The record normally includes block and inode usage, soft limits, and hard limits for each filesystem. Do not edit current-usage fields unless the filesystem-specific documentation explicitly instructs you to do so; administrators normally change limits, while accounting tools maintain usage.

Set grace periods interactively with:

sudo edquota -t

Use this when policy requires a different interval for block or inode overages. Grace-period format and supported behavior should be checked against the installed quota implementation.

Noninteractive setting with setquota

setquota is useful for scripts and repeatable administration. For example, the following expresses soft and hard block limits for user alice:

sudo setquota -u alice 3145728 5242880 0 0 /home

The first two numeric values represent the soft and hard block limits; the final two represent inode soft and hard limits, set to zero in this example. The exact unit expected by the installed implementation must be verified before applying values in production. A numeric value that appears to represent bytes may instead be interpreted as filesystem blocks or KiB.

This example sets only inode limits for the developers group:

sudo setquota -g developers 0 0 50000 60000 /home

Here, the block limits are unset or unlimited according to the implementation, while the inode soft and hard limits are set to the final two values.

Inspecting limits and usage

Show a user's quota:

quota -u alice

Show a group's quota:

quota -g developers

Generate an administrator report for all users and groups:

sudo repquota -aug

Check whether quota enforcement is enabled for the mount point:

sudo quotaon -p /home

Quota reports typically show current block usage, block soft and hard limits, current inode usage, inode soft and hard limits, and any active or expired grace period.

CommandPurposeTypical targetNotes
quota -u aliceDisplay an individual user's usage and limits.UserRun as the user for a personal summary or with administrative privileges for broader visibility.
quota -g developersDisplay a group's usage and limits.GroupUseful for shared project allocations.
sudo repquota -augGenerate a quota report.All configured users and groupsOptions and output format vary by implementation.
sudo quotaon -p /homeInspect enforcement state.Filesystem mount pointDoes not itself enable quotas.
sudo edquota -u aliceEdit limits interactively.UserUses the configured editor.
sudo edquota -g developersEdit limits interactively.GroupRequires group quota support.
sudo setquota ...Set limits noninteractively.User or groupVerify argument order and units on the installed system.
sudo quotacheck -cugm /homeCreate or refresh accounting data.Mounted ext-family filesystemCan be resource intensive and should be scheduled carefully.

Practical examples

Example: a user's block-space policy

Suppose alice receives a 3 GiB soft limit and a 5 GiB hard limit on /home. Configure the values using the local quota tool's expected units, then inspect the result:

sudo setquota -u alice 3145728 5242880 0 0 /home
quota -u alice

After usage exceeds the soft limit, explain to the user that the grace timer is active and that files should be removed or moved before it expires. If usage reaches the hard limit, writes and file expansions requiring additional allocation fail immediately. If the grace timer expires first, usage must be reduced below the soft limit before further allocation is permitted.

Example: inode exhaustion from many small files

Give a test user a generous block allowance but a low inode allowance. A workload that creates thousands of tiny files can then fail with an inode-related quota error while df still reports considerable free space. Run the user's quota report and compare inode usage with the inode soft and hard limits.

This distinction is important when diagnosing applications that create caches, mail messages, session files, or temporary objects. Deleting unnecessary files reduces inode usage as well as block usage.

Example: a shared project group

For a project group named developers, assign a group block quota to control the team's collective use of a shared filesystem. Members can contribute files to the shared area, but the group's total allocation remains bounded. Review the group report regularly and increase the limit when the project's approved storage allocation changes.

sudo setquota -g developers 0 0 50000 60000 /home
quota -g developers
sudo repquota -aug

Group quotas do not replace permissions. Configure ownership, set-group-ID directories, access control lists, and group membership separately so that the intended users can access the project area.

Filesystem implementation differences

Filesystem familyQuota enablement approachAdministrative toolsKey caution
ext2/ext3/ext4Commonly uses usrquota and grpquota mount options with quota files or supported filesystem-native quota features.quotacheck, quotaon, quotaoff, edquota, setquota, and repquota.Persistent mount options, accounting method, and units depend on the distribution and filesystem feature set.
XFSUses XFS-specific quota support and mount-option behavior.xfs_quota and XFS-specific administration commands.Do not blindly apply ext-family quota-file commands to XFS; consult the installed XFS documentation.

XFS uses its own quota tooling. Examples for inspecting XFS quota information include:

sudo xfs_quota -x -c 'report -h' /mountpoint
sudo xfs_quota -x -c 'quota -u alice' /mountpoint

Quota setup differs by filesystem and Linux distribution. Always verify the filesystem-specific documentation, mount options, command syntax, and units before applying a production policy.

Verification and maintenance

After setup or a policy change, verify each layer:

  1. Confirm that the intended path is on the expected filesystem with findmnt or df -T.
  2. Confirm that the active mount options include the required quota support.
  3. Confirm that accounting data exists and is current.
  4. Confirm enforcement with quotaon -p or the filesystem-specific status command.
  5. Check the assigned limits and current block and inode consumption for representative users and groups.
  6. Perform a controlled test with a test account if the policy is new or safety-critical.

Run a quota consistency scan when accounting data is absent, stale, or damaged; during initial setup; after recovery; or after an unclean filesystem event when accounting may no longer match actual ownership and allocation. A scan can be expensive, so use a maintenance window and the filesystem-appropriate procedure. On an ext-family quota-file setup, the common starting point is:

sudo quotacheck -cugm /home

After reconciling accounting, re-enable enforcement if it was disabled during maintenance and verify the result again.

Troubleshooting quota problems

Quota commands say quotas are not enabled

  • Inspect the filesystem and active mount options with findmnt or mount.
  • Check enforcement with sudo quotaon -p /home.
  • Determine whether accounting data was initialized.

Correct the persistent mount configuration, remount or reboot as appropriate, initialize or refresh accounting, and run quotaon. If the filesystem is XFS, use its quota model instead of assuming an ext-family workflow.

A user cannot create files even though disk space appears free

Check both measurements:

quota -u alice
df -h /home
df -i /home

The user may have reached a hard block limit, remained above a soft limit after grace expiration, or reached an inode limit. Remove or move files, increase the correct limit when approved, or correct an unintended assignment.

Quota reports show missing or incorrect usage

Possible causes include stale or inconsistent accounting data, an unclean shutdown, or never having completed the initial quota scan. Check mount and enforcement status, then run the filesystem-appropriate consistency check during a maintenance window. Reconcile accounting and verify reports before restoring normal enforcement.

Only some users are constrained

Limits may have been assigned to users but not groups, or to groups but not users. The affected path may also be on a different filesystem without quotas. Identify the filesystem containing the path, inspect the account's primary and supplementary groups, and review both user and group reports. Apply the policy to the correct subject and filesystem.

Exam-relevant summary

  • Quotas are enforced per filesystem, not automatically across the whole host.
  • User quotas apply to individual accounts; group quotas apply to a group's collective usage.
  • Soft limits can be exceeded temporarily during a grace period; hard limits are absolute.
  • After grace expiration, remaining above a soft limit causes further allocation to be denied.
  • Block quotas limit disk space; inode quotas limit the number of filesystem objects.
  • Both block and inode quotas can have soft and hard thresholds.
  • Quota accounting tracks usage; quota enforcement prevents disallowed allocations.
  • Mount options and administration commands differ between ext-family filesystems and XFS.
  • Always verify active mount options, accounting state, enforcement state, current usage, and assigned limits.