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:

  1. Mount Options: Update /etc/fstab to include usrquota and/or grpquota in the options field for the partition.
  2. Quota Database: Run quotacheck -cugm /mountpoint to create the aquota.user and aquota.group index files.
  3. 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:

For both blocks and inodes, administrators assign two types of constraints:

Editing User and Group Quotas

To configure storage rules for a specific user:

sudo edquota username

To configure quotas for a specific group:

sudo edquota -g groupname

The 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

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 -t

This 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 user3

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