4.5. GFS2 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. 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.
To prevent a performance slowdown, a GFS2 node synchronizes updates to the quota file only periodically. The "fuzzy" quota accounting can allow users or groups to slightly exceed the set limit. To minimize this, GFS2 dynamically reduces the synchronization period as a "hard" quota limit is approached.
GFS2 uses its gfs2_quota command to manage quotas. Other Linux quota facilities cannot be used with GFS2.

4.5.1. 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 gfs2_quota command. The command only needs to be run on a single node where GFS2 is mounted.
By default, quota enforcement is not set on GFS2 file systems. To enable quota accounting, use the quota= of the mount command when mounting the GFS2 file system, as described in Section 4.5.4, “Enabling/Disabling Quota Enforcement”.

Usage

Setting Quotas, Hard Limit
gfs2_quota limit -u User -l Size -f MountPoint
gfs2_quota limit -g Group -l Size -f MountPoint
Setting Quotas, Warn Limit
gfs2_quota warn -u User -l Size -f MountPoint
gfs2_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 GFS2 file system to which the actions apply.

Examples

This example sets the hard limit for user Bert to 1024 megabytes (1 gigabyte) on file system /mygfs2.
gfs2_quota limit -u Bert -l 1024 -f /mygfs2
This example sets the warn limit for group ID 21 to 50 kilobytes on file system /mygfs2.
gfs2_quota warn -g 21 -l 50 -k -f /mygfs2

4.5.2. Displaying Quota Limits and Usage

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

Usage

Displaying Quota Limits for a User
gfs2_quota get -u User -f MountPoint
Displaying Quota Limits for a Group
gfs2_quota get -g Group -f MountPoint
Displaying Entire Quota File
gfs2_quota list -f MountPoint
User
A user ID to display information about a specific user. It can be either a user name from the password file or the UID number.
Group
A group ID to display information about a specific group. It can be either a group name from the group file or the GID number.
MountPoint
Specifies the GFS2 file system to which the actions apply.

Command Output

GFS2 quota information from the gfs2_quota command is displayed as follows:
user User: limit:LimitSize warn:WarnSize value:Value

group Group: limit:LimitSize warn:WarnSize value:Value

The LimitSize, WarnSize, and Value numbers (values) are in units of megabytes by default. Adding the -k, -s, or -b flags to the command line change the units to kilobytes, sectors, or file system blocks, respectively.
User
A user name or ID to which the data is associated.
Group
A group name or ID to which the data is associated.
LimitSize
The hard limit set for the user or group. This value is zero if no limit has been set.
Value
The actual amount of disk space used by the user or group.

Comments

When displaying quota information, the gfs2_quota command does not resolve UIDs and GIDs into names if the -n option is added to the command line.
Space allocated to GFS2's hidden files can be left out of displayed values for the root UID and GID by adding the -d option to the command line. This is useful when trying to match the numbers from gfs2_quota with the results of a du command.

Examples

This example displays quota information for all users and groups that have a limit set or are using any disk space on file system /mygfs2.
gfs2_quota list -f /mygfs2
This example displays quota information in sectors for group users on file system /mygfs2.
gfs2_quota get -g users -f /mygfs2 -s

4.5.3. Synchronizing Quotas

GFS2 stores all quota information in its own internal file on disk. A GFS2 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, GFS2 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 gfs2_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 gfs2_quota sync command to synchronize the quota information from a node to the on-disk quota file between the automatic updates performed by GFS2.

Usage

Synchronizing Quota Information
gfs2_quota sync -f MountPoint
MountPoint
Specifies the GFS2 file system to which the actions apply.
Tuning the Time Between Synchronizations
gfs2_tool settune MountPoint quota_quantum Seconds
MountPoint
Specifies the GFS2 file system to which the actions apply.
Seconds
Specifies the new time period between regular quota-file synchronizations by GFS2. Smaller values may increase contention and slow down performance.

Examples

This example synchronizes the quota information from the node it is run on to file system /mygfs2.
gfs2_quota sync -f /mygfs2
This example changes the default time period between regular quota-file updates to one hour (3600 seconds) for file system /mygfs2 on a single node.
gfs2_tool settune /mygfs2 quota_quantum 3600

4.5.4. Enabling/Disabling Quota Enforcement

In GFS2 file systems, quota enforcement is disabled by default. To enable quota enforcement for a file system, mount the file system with the quota=on option specified.

Usage

mount -o quota=on BlockDevice MountPoint
To mount a file system with quota enforcement disabled, mount the file system with the quota=off option specified. This is the default setting.
mount -o quota=off BlockDevice MountPoint
-o quota={on|off}
Specifies that quota enforcement is enabled or disabled when the file system is mounted.
BlockDevice
Specifies the block device where the GFS2 file system resides.
MountPoint
Specifies the directory where the GFS2 file system should be mounted.

Examples

In this example, the GFS2 file system on /dev/vg01/lvol0 is mounted on the /mygfs2 directory with quota enforcement enabled.
mount -o quota=on /dev/vg01/lvol0 /mygfs2

4.5.5. Enabling Quota Accounting

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.

Usage

mount -o quota=account BlockDevice MountPoint
-o quota=account
Specifies that user and group usage statistics are maintained by the file system, even though the quota limits are not enforced.
BlockDevice
Specifies the block device where the GFS2 file system resides.
MountPoint
Specifies the directory where the GFS2 file system should be mounted.

Example

In this example, the GFS2 file system on /dev/vg01/lvol0 is mounted on the /mygfs2 directory with quota accounting enabled.
mount -o quota=account /dev/vg01/lvol0 /mygfs2
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.