Chapter 17. Disk Quotas
quota RPM must be installed to implement disk quotas.
Note
17.1. Configuring Disk Quotas Copy linkLink copied to clipboard!
- Enable quotas per file system by modifying the
/etc/fstabfile. - Remount the file system(s).
- Create the quota database files and generate the disk usage table.
- Assign quota policies.
17.1.1. Enabling Quotas Copy linkLink copied to clipboard!
Procedure 17.1. Enabling Quotas
- Log in as root.
- Edit the
/etc/fstabfile. - Add either the
usrquotaorgrpquotaor both options to the file systems that require quotas.
Example 17.1. Edit /etc/fstab
vim type the following:
vim /etc/fstab
# vim /etc/fstab
Example 17.2. Add Quotas
/home file system has both user and group quotas enabled.
Note
/home partition was created during the installation of Red Hat Enterprise Linux. The root (/) partition can be used for setting quota policies in the /etc/fstab file.
17.1.2. Remounting the File Systems Copy linkLink copied to clipboard!
usrquota or grpquota or both options, remount each file system whose fstab entry has been modified. If the file system is not in use by any process, use one of the following methods:
- Run the
umountcommand followed by themountcommand to remount the file system. See themanpage for bothumountandmountfor the specific syntax for mounting and unmounting various file system types. - Run the
mount -o remount file-systemcommand (wherefile-systemis the name of the file system) to remount the file system. For example, to remount the/homefile system, run themount -o remount /homecommand.
17.1.3. Creating the Quota Database Files Copy linkLink copied to clipboard!
quotacheck command.
quotacheck command examines quota-enabled file systems and builds a table of the current disk usage per file system. The table is then used to update the operating system's copy of disk usage. In addition, the file system's disk quota files are updated.
Note
quotacheck command has no effect on XFS as the table of disk usage is completed automatically at mount time. See the man page xfs_quota(8) for more information.
Procedure 17.2. Creating the Quota Database Files
- Create the quota files on the file system using the following command:
quotacheck -cug /file system
# quotacheck -cug /file systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Generate the table of current disk usage per file system using the following command:
quotacheck -avug
# quotacheck -avugCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- c
- Specifies that the quota files should be created for each file system with quotas enable.
- u
- Checks for user quotas.
- g
- Checks for group quotas. If only
-gis specified, only the group quota file is created.
-u or -g options are specified, only the user quota file is created.
- a
- Check all quota-enabled, locally-mounted file systems
- v
- Display verbose status information as the quota check proceeds
- u
- Check user disk quota information
- g
- Check group disk quota information
quotacheck has finished running, the quota files corresponding to the enabled quotas (either user or group or both) are populated with data for each quota-enabled locally-mounted file system such as /home.
17.1.4. Assigning Quotas per User Copy linkLink copied to clipboard!
edquota command.
- User must exist prior to setting the user quota.
Procedure 17.3. Assigning Quotas per User
- To assign the quota for a user, use the following command:
edquota username
# edquota usernameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace username with the user to which you want to assign the quotas. - To verify that the quota for the user has been set, use the following command:
quota username
# quota usernameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 17.3. Assigning Quotas to a user
/etc/fstab for the /home partition (/dev/VolGroup00/LogVol02 in the following example) and the command edquota testuser is executed, the following is shown in the editor configured as the default for the system:
Disk quotas for user testuser (uid 501): Filesystem blocks soft hard inodes soft hard /dev/VolGroup00/LogVol02 440436 0 0 37418 0 0
Disk quotas for user testuser (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/VolGroup00/LogVol02 440436 0 0 37418 0 0
Note
EDITOR environment variable is used by edquota. To change the editor, set the EDITOR environment variable in your ~/.bash_profile file to the full path of the editor of your choice.
inodes column shows how many inodes the user is currently using. The last two columns are used to set the soft and hard inode limits for the user on the file system.
Example 17.4. Change Desired Limits
Disk quotas for user testuser (uid 501): Filesystem blocks soft hard inodes soft hard /dev/VolGroup00/LogVol02 440436 500000 550000 37418 0 0
Disk quotas for user testuser (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/VolGroup00/LogVol02 440436 500000 550000 37418 0 0
quota testuser
# quota testuser
Disk quotas for user username (uid 501):
Filesystem blocks quota limit grace files quota limit grace
/dev/sdb 1000* 1000 1000 0 0 0
17.1.5. Assigning Quotas per Group Copy linkLink copied to clipboard!
- Group must exist prior to setting the group quota.
Procedure 17.4. Assigning Quotas per Group
- To set a group quota, use the following command:
edquota -g groupname
# edquota -g groupnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - To verify that the group quota is set, use the following command:
Emptyquota -g groupname
# Emptyquota -g groupnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 17.5. Assigning quotas to group
devel group, use the command:
edquota -g devel
# edquota -g devel
Disk quotas for group devel (gid 505): Filesystem blocks soft hard inodes soft hard /dev/VolGroup00/LogVol02 440400 0 0 37418 0 0
Disk quotas for group devel (gid 505):
Filesystem blocks soft hard inodes soft hard
/dev/VolGroup00/LogVol02 440400 0 0 37418 0 0
quota -g devel
# quota -g devel
17.1.6. Setting the Grace Period for Soft Limits Copy linkLink copied to clipboard!
edquota -t
# edquota -t
Important
edquota commands operate on quotas for a particular user or group, the -t option operates on every file system with quotas enabled.