LinuxCommandLibrary

quotacheck

Scan filesystem for disk quota inconsistencies

TLDR

Check quotas on all mounted non-NFS filesystems

$ sudo quotacheck --all
copy

Force check even if quotas are enabled (this can cause damage or loss to quota files)
$ sudo quotacheck --force [mountpoint]
copy

Check quotas on a given filesystem in debug mode
$ sudo quotacheck --debug [mountpoint]
copy

Check quotas on a given filesystem, displaying the progress
$ sudo quotacheck --verbose [mountpoint]
copy

Check user quotas
$ sudo quotacheck --user [user] [mountpoint]
copy

Check group quotas
$ sudo quotacheck --group [group] [mountpoint]
copy

SYNOPSIS

quotacheck [options] [filesys ...]

PARAMETERS

-a
    Check all mounted filesystems that support quotas, as listed in /etc/mtab.

-c
    Create new quota files. This option instructs quotacheck to skip existing quota files and create new ones based on the current disk usage.

-g
    Check group quotas only. By default, both user and group quotas are checked if neither -u nor -g is specified.

-u
    Check user quotas only. By default, both user and group quotas are checked if neither -u nor -g is specified.

-v
    Be verbose, showing scan progress and information about quota file updates.

-f
    Force check even if the filesystem is mounted and active. Use this option with caution, as it can lead to inaccurate results or data corruption if the filesystem is heavily used.

-i / -n
    Do not repair inconsistencies; report them only. This makes quotacheck run in a 'read-only' mode without modifying quota files.

-R
    When used with -a, also check the root filesystem. The root filesystem is often skipped by default for safety reasons.

-L
    Disable verbose logging. This can be useful in scripts where progress output is not desired.

-M
    Do not remount filesystems read-only when scanning with -a. This can be useful on systems where remounting is problematic, but it increases the risk of inconsistencies.

-P
    Display a progress bar during the scan, which can be helpful for very large filesystems.

-T
    Do not truncate existing quota files. This can be useful in specific recovery scenarios.

-x filesystem
    Exclude the specified filesystem from the check, typically used with -a.

DESCRIPTION

quotacheck is a Linux command-line utility used to verify and repair the consistency of disk quota files on filesystems. It scans the specified filesystems, builds a fresh table of current disk usage (blocks and inodes) for all users and groups, and then compares this information with the data stored in the existing quota files (e.g., aquota.user, aquota.group, or older quota.user, quota.group). If any discrepancies are found, quotacheck updates the quota files to reflect the actual disk usage, ensuring the integrity of the quota system.

It is commonly run after system crashes or unexpected shutdowns to correct potential inconsistencies. While it can be run on mounted filesystems using the -f (force) option, it is generally recommended to unmount the filesystem first to prevent data corruption or inaccurate results during the scan. This command is crucial for maintaining accurate disk usage tracking and enforcement in a multi-user environment.

CAVEATS

Running quotacheck on a mounted filesystem with the -f option is generally not recommended as it can lead to data corruption or inaccurate results if the filesystem is actively being written to. For best results and safety, the filesystem should ideally be unmounted before running quotacheck. If unmounting is not feasible, consider remounting it read-only. The scan can be time-consuming, especially for large filesystems with a high number of files and directories.

QUOTA FILE LOCATIONS

Quota files are typically named aquota.user and aquota.group (or quota.user and quota.group for older systems) and usually reside in the root directory of the filesystem being checked. Their correct placement is critical for the quota system to function properly.

INTEGRATION WITH SYSTEM STARTUP

quotacheck is often run automatically during system startup by init scripts if quotas are enabled for a filesystem. This usually occurs after fsck has completed its checks, ensuring quota consistency before users log in and start modifying files on the filesystem.

HISTORY

Disk quotas have been a fundamental feature of Unix-like operating systems for decades. The quotacheck utility has been an integral part of the quota system since its early implementations, designed to ensure the integrity of quota files. Its core functionality has remained consistent, adapting over time to new quota file formats (such as the aquota format) and evolving kernel quota modules to maintain compatibility and efficiency across different Linux distributions and kernel versions.

SEE ALSO

quota(1), edquota(8), repquota(8), quotaon(8), quotaoff(8)

Copied to clipboard