Quota Management

File-system quotas are used to limit the amount of file system space a user or group can use. A user or group does not have a quota limit until one is set. When a GFS2 file system is mounted with the quota = on or quota = account option, GFS2 keeps track of the space used by each user and group even when there are no limits in place. GFS2 updates quota information in a transactional way so system crashes do not require quota usages to be reconstructed.

Configuring Disk Quotas

To implement disk quotas, use the following steps:

  • Set up quotas in enforcement or accounting mode.

  • Initialize the quota database file with current block usage information.

Setting Up Quotas in Enforcement or Accounting Mode

In GFS2 file systems, quotas are disabled by default. To enable quotas for a file system, mount the file system with the quota = on option specified. It is possible to keep track of disk usage and maintain quota accounting for every user and group without enforcing the limit and warn values. To do this, mount the file system with the quota = account option specified.

Setting Quotas

  • Two quota settings are available for each user ID (UID) or group ID (GID): a hard limit and a warn limit.

  • A hard limit is the amount of space that can be used. The file system will not let the user or group use more than that amount of disk space. A hard limit value of zero means that no limit is enforced.

  • A warn limit is usually a value less than the hard limit. The file system will notify the user or group when the warn limit is reached to warn them of the amount of space they are using.

  • A warn limit value of zero means that no limit is enforced. Limits are set using the gfs_quota command. The command only needs to be run on a single node where GFS is mounted.

We can use the following commands and their associated man pages:

  • quota on -/fs Enables quotas for the /fs file system.

  • quota off- Disables quota tracking.

  • edquota-name Edits the quota settings for user name. Can also be used to set defaults.quota -Allows users to see their current resource consumption and limits.

  • repquota-Generates a report of disk consumption by all users for a quota-enabled file system. Quota check- Scans a file system

Usage

Setting Quotas, Hard Limit

gfs_quota limit -u User -l Size -f MountPoint
gfs_quota limit -g Group -l Size -f MountPoint
Setting Quotas, Warn Limit
gfs_quota warn -u User -l Size -f MountPoint
gfs_quota warn -g Group -l Size -f MountPoint

- User
  
A user ID to limit or warn. It can be either a user name from the password file or the UID number.

- Group

A group ID to limit or warn. It can be either a group name from the group file or the GID number.

- Size

Specifies the new value to limit or warn. By default, the value is in units of megabytes. The additional `-k`, `-s` and `-b` flags change the units to kilobytes, sectors, and file-system blocks, respectively.

- MountPoint

Specifies the GFS file system to which the actions apply.

## Creating the Quota Database Files

- After each quota-enabled file system is mounted, the system is capable of working with disk quotas.
  
- However, the file system itself is not yet ready to support quotas.
  
- The next step is to run the quotacheck command. The 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.
  
- To create the quota files on the file system, use the -u and the -g options of the quotacheck command; both of these options must be specified for user and group quotas to be initialized. For example, if quotas are enabled for the /home file system, 
create the files in the /home directory:

```sh
quotacheck -ug /home

Assigning Quotas per User

The last step is assigning the disk quotas with the edquota command. Note that if you have mounted your file system in accounting mode (with the quota=account option specified), the quotas are not enforced.

To configure the quota for a user, as root in a shell prompt, execute the command:

edquotausername

Perform this step for each user who needs a quota. For example, if a quota is enabled in /etc/fstab for the /home partition (/dev/VolGroup00/LogVol02 in the example below) and the command edquota testuser is executed, the following is shown in the editor configured as the default for the system:

quota username

Assigning Quotas per Group

Quotas can also be assigned on a per-group basis. Note that if you have mounted your file system in accounting mode (with the account=on option specified), the quotas are not enforced.

To set a group quota for the devel group (the group must exist prior to
setting the group quota), use the following command:
edquota -g devel

To verify that the group quota has been set, use the following command: quota -g devel

Displaying Quota Limits and Usage. Quota limits and current usage can be displayed for a specific user or group using the gfs_quota get command. The entire contents of the quota file can also be displayed using the gfs_quota list command, in which case all IDs with a non-zero hard limit, warn limit, or value are listed.

Synchronizing Quotas

  • GFS stores all quota information in its own internal file on disk.

  • A GFS node does not update this quota file for every file-system write; rather, it updates the quota file once every 60 seconds.

  • This is necessary to avoid contention among nodes writing to the quota file, which would cause a slowdown in performance.

  • As a user or group approaches their quota limit, GFS dynamically reduces the time between its quota-file updates to prevent the limit from being exceeded.

  • The normal time period between quota synchronizations is a tunable parameter, quota_quantum, and can be changed using the gfs_tool command.

  • By default, the time period is 60 seconds. Also, the quota_quantum parameter must be set on each node and each time the file system is mounted. (Changes to the quota_quantum parameter are not persistent across unmounts.)

  • You can use the gfs_quota sync command to synchronize the quota information from a node to the on-disk quota file between the automatic updates performed by GFS.

Subscribe For More Content