17.9 About Disk Quotas

17.9.1 Enabling Disk Quotas on File Systems
17.9.2 Assigning Disk Quotas to Users and Groups
17.9.3 Setting the Grace Period
17.9.4 Displaying Disk Quotas
17.9.5 Enabling and Disabling Disk Quotas
17.9.6 Reporting on Disk Quota Usage
17.9.7 Maintaining the Accuracy of Disk Quota Reporting
Note

For information about how to configure quotas for the XFS file system, see Section 18.23, “Setting Quotas on an XFS File System”.

You can set disk quotas to restrict the amount of disk space (blocks) that users or groups can use, to limit the number of files (inodes) that users or groups can create, and to notify you when usage is reaching a specified limit. A hard limit specifies the maximum number of blocks or inodes available to a user or group on the file system. Users or groups can exceed a soft limit for a period of time known as a grace period.

17.9.1 Enabling Disk Quotas on File Systems

To enable user or group disk quotas on a file system:

  1. Install or update the quota package:

    # yum install quota
  2. Include the usrquota or grpquota options in the file system's /etc/fstab entry, for example:

    /dev/sdb1       /home        ext4    usrquota,grpquota   0 0
  3. Remount the file system:

    # mount –o remount /home
  4. Create the quota database files:

    # quotacheck –cug /home

    This command creates the files aquota.user and aquota.group in the root of the file system (/home in this example).

For more information, see the quotacheck(8) manual page.

17.9.2 Assigning Disk Quotas to Users and Groups

To configure the disk quota for a user:

  1. Enter the following command for a user:

    # edquota username

    or for a group:

    # edquota –g group

    The command opens a text file opens in the default editor defined by the EDITOR environment variable, allowing you to specify the limits for the user or group, for example:

    Disk quotas for user guest (uid 501)
    Filesystem  blocks  soft  hard  inodes  soft  hard
     /dev/sdb1   10325     0     0    1054     0     0

    The blocks and inodes entries show the user's currently usage on a file system.

    Tip

    Setting a limit to 0 disables quota checking and enforcement for the corresponding blocks or inodes category.

  2. Edit the soft and hard block limits for number of blocks and inodes, and save and close the file.

Alternatively, you can use the setquota command to configure quota limits from the command-line. The –p option allows you to apply quota settings from one user or group to another user or group.

For more information, see the edquota(8) and setquota(8) manual pages.

17.9.3 Setting the Grace Period

To configure the grace period for soft limits:

  1. Enter the following command:

    # edquota -t

    The command opens a text file opens in the default editor defined by the EDITOR environment variable, allowing you to specify the grace period, for example:

    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/sdb1            7days                  7days 
  2. Edit the grace periods for the soft limits on the number of blocks and inodes, and save and close the file.

For more information, see the edquota(8) manual page.

17.9.4 Displaying Disk Quotas

To display a user's disk usage:

# quota username

To display a group's disk usage:

# quota -g group

To display information about file systems where usage is over the quota limits:

# quota -q

Users can also use the quota command to display their own and their group's usage.

For more information, see the quota(1) manual page.

17.9.5 Enabling and Disabling Disk Quotas

To disable disk quotas for all users, groups on a specific file system:

# quotaoff -guv filesystem

To disable disk quotas for all users, groups, and file systems:

# quotaoff -aguv

To re-enable disk quotas for all users, groups, and file systems:

# quotaon -aguv

For more information, see the quotaon(1) manual page.

17.9.6 Reporting on Disk Quota Usage

To display the disk quota usage for a file system:

# repquota filesystem

To display the disk quota usage for all file systems:

# repquota -a

For more information, see the repquota(8) manual page.

17.9.7 Maintaining the Accuracy of Disk Quota Reporting

Uncontrolled system shutdowns can lead to inaccuracies in disk quota reports.

To rebuild the quota database for a file system:

  1. Disable disk quotas for the file system:

    # quotaoff -guv filesystem
  2. Unmount the file system:

    # umount filesystem
  3. Enter the following command to rebuild the quota databases:

    # quotacheck -guv filesystem
  4. Mount the file system:

    # mount filesystem
  5. Enable disk quotas for the file system:

    # quotaoff -guv filesystem

For more information, see the quotacheck(8) manual page.