How to Use edquota for Linux Quota Administration
Disk quota management is a crucial administrative task in multi-user
Linux environments to prevent individual users or groups from exhausting
storage resources. This article covers how the Linux operating system
handles quota administration using the edquota command,
including prerequisites, understanding block and inode metrics,
configuring soft and hard limits, setting grace periods, and duplicating
quota settings across multiple users.
Prerequisites for Quota Administration
Before using edquota, disk quotas must be supported and
enabled on the target filesystem:
- Mount Options: Update
/etc/fstabto includeusrquotaand/orgrpquotain the options field for the partition. - Quota Database: Run
quotacheck -cugm /mountpointto create theaquota.userandaquota.groupindex files. - Activation: Enable quotas on the system using
quotaon -v /mountpoint.
Once initialized, the edquota utility serves as the
primary tool to modify these binary index files safely.
Understanding edquota Metrics and Limits
The edquota command opens an interactive text editor
(determined by the $EDITOR environment variable, defaulting
to vi or nano) populated with quota rules for
a designated user or group.
Each entry defines allocations across two resources:
- Blocks: Represents actual disk space consumed (typically measured in 1-kilobyte units).
- Inodes: Represents the total number of distinct files, directories, and links created.
For both blocks and inodes, administrators assign two types of constraints:
- Soft Limit: A threshold that generates a warning when exceeded. Users can temporarily bypass this limit during an allotted grace period.
- Hard Limit: An absolute ceiling that cannot be crossed. If reached, the system immediately rejects write operations or file creation.
Editing User and Group Quotas
To configure storage rules for a specific user:
sudo edquota usernameTo configure quotas for a specific group:
sudo edquota -g groupnameThe editor opens a formatted layout similar to the following:
Disk quotas for user alice (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 4096 50000 60000 12 100 120
- The first
blockscolumn and the firstinodescolumn display current usage and are updated automatically by the system. - The
softandhardcolumns are manually defined. Setting a limit to0disables that constraint (unlimited). - Save and exit the editor to apply the changes immediately without restarting services.
Configuring Grace Periods
When a user exceeds a soft limit, a grace period countdown begins. If the user fails to reduce their usage below the soft limit before the timer expires, the soft limit acts as a hard limit.
To change the default grace period (typically 7 days):
sudo edquota -tThis presents an editor interface specifying time frames for blocks and inodes:
Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/dev/sda1 7days 7days
Adjust the units as needed (e.g., 48hours,
14days) and save the file.
Duplicating Quotas Across Users
Manually configuring quotas for dozens or hundreds of accounts is
inefficient. The edquota command provides a prototype flag
(-p) to duplicate an established configuration to other
accounts:
sudo edquota -p prototype_user user1 user2 user3This applies the exact block and inode thresholds configured on
prototype_user to the target accounts while preserving
their current usage counts. It can also be combined with shell
expansions to apply limits to entire ranges of users:
sudo edquota -p standard_user $(getent passwd | awk -F: '$3 >= 1000 {print $1}')Verifying Quota Assignments
After administering quotas with edquota, verify that
settings have taken effect:
- View individual user quota:
quota -vs username - Generate a system-wide quota report:
repquota -avugs