Este contenido no está disponible en el idioma seleccionado.
Chapter 23. Limiting storage space usage on XFS with quotas
You can restrict the amount of disk space available to users or groups by implementing disk quotas. You can also define a warning level at which system administrators are informed before a user consumes too much disk space or a partition becomes full.
The XFS quota subsystem manages limits on disk space (blocks) and file (inode) usage. XFS quotas control or report on usage of these items on a user, group, or directory or project level. Group and project quotas are only mutually exclusive on older non-default XFS disk formats.
When managing on a per-directory or per-project basis, XFS manages the disk usage of directory hierarchies associated with a specific project.
23.1. Disk quotas
In most computing environments, disk space is not infinite. The quota subsystem provides a mechanism to control usage of disk space.
You can configure disk quotas for individual users as well as user groups on the local file systems. This makes it possible to manage the space allocated for user-specific files (such as email) separately from the space allocated to the projects that a user works on. The quota subsystem warns users when they exceed their allotted limit, but allows some extra space for current work (hard limit/soft limit).
If quotas are implemented, you need to check if the quotas are exceeded and make sure the quotas are accurate. If users repeatedly exceed their quotas or consistently reach their soft limits, a system administrator can either help the user determine how to use less disk space or increase the user’s disk quota.
You can set quotas to control:
- The number of consumed disk blocks.
- The number of inodes, which are data structures that contain information about files in UNIX file systems. Because inodes store file-related information, this allows control over the number of files that can be created.
23.2. The xfs_quota
tool
You can use the xfs_quota
tool to manage quotas on XFS file systems. In addition, you can use XFS file systems with limit enforcement turned off as an effective disk usage accounting system.
The XFS quota system differs from other file systems in a number of ways. Most importantly, XFS considers quota information as file system metadata and uses journaling to provide a higher level guarantee of consistency.
Additional resources
-
xfs_quota(8)
man page on your system
23.3. File system quota management in XFS
The XFS quota subsystem manages limits on disk space (blocks) and file (inode) usage. XFS quotas control or report on usage of these items on a user, group, or directory or project level. Group and project quotas are only mutually exclusive on older non-default XFS disk formats.
When managing on a per-directory or per-project basis, XFS manages the disk usage of directory hierarchies associated with a specific project.
23.4. Enabling disk quotas for XFS
Enable disk quotas for users, groups, and projects on an XFS file system. Once quotas are enabled, the xfs_quota
tool can be used to set limits and report on disk usage.
Procedure
Enable quotas for users:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mount -o uquota /dev/xvdb1 /xfs
# mount -o uquota /dev/xvdb1 /xfs
Replace
uquota
withuqnoenforce
to allow usage reporting without enforcing any limits.Enable quotas for groups:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mount -o gquota /dev/xvdb1 /xfs
# mount -o gquota /dev/xvdb1 /xfs
Replace
gquota
withgqnoenforce
to allow usage reporting without enforcing any limits.Enable quotas for projects:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow mount -o pquota /dev/xvdb1 /xfs
# mount -o pquota /dev/xvdb1 /xfs
Replace
pquota
withpqnoenforce
to allow usage reporting without enforcing any limits.Alternatively, include the quota mount options in the
/etc/fstab
file. The following example shows entries in the/etc/fstab
file to enable quotas for users, groups, and projects, respectively, on an XFS file system. These examples also mount the file system with read/write permissions:Copy to Clipboard Copied! Toggle word wrap Toggle overflow vim /etc/fstab
# vim /etc/fstab /dev/xvdb1 /xfs xfs rw,quota 0 0 /dev/xvdb1 /xfs xfs rw,gquota 0 0 /dev/xvdb1 /xfs xfs rw,prjquota 0 0
Additional resources
-
xfs(5)
andxfs_quota(8)
man pages on your system
23.5. Reporting XFS usage
Use the xfs_quota
tool to set limits and report on disk usage. By default, xfs_quota
is run interactively, and in basic mode. Basic mode subcommands simply report usage, and are available to all users.
Prerequisites
- Quotas have been enabled for the XFS file system. See Enabling disk quotas for XFS.
Procedure
Start the
xfs_quota
shell:Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota
# xfs_quota
Show usage and limits for the given user:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> quota username
xfs_quota> quota username
Show free and used counts for blocks and inodes:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> df
xfs_quota> df
Run the help command to display the basic commands available with
xfs_quota
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> help
xfs_quota> help
Specify
q
to exitxfs_quota
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> q
xfs_quota> q
Additional resources
-
xfs_quota(8)
man page on your system
23.6. Modifying XFS quota limits
Start the xfs_quota
tool with the -x
option to enable expert mode and run the administrator commands, which allow modifications to the quota system. The subcommands of this mode allow actual configuration of limits, and are available only to users with elevated privileges.
Prerequisites
- Quotas have been enabled for the XFS file system. See Enabling disk quotas for XFS.
Procedure
Start the
xfs_quota
shell with the-x
option to enable expert mode:Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota -x /path
# xfs_quota -x /path
Report quota information for a specific file system:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> report /path
xfs_quota> report /path
For example, to display a sample quota report for
/home
(on/dev/blockdevice
), use the commandreport -h /home
. This displays output similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow User quota on /home (/dev/blockdevice) Blocks User ID Used Soft Hard Warn/Grace ---------- --------------------------------- root 0 0 0 00 [------] testuser 103.4G 0 0 00 [------]
User quota on /home (/dev/blockdevice) Blocks User ID Used Soft Hard Warn/Grace ---------- --------------------------------- root 0 0 0 00 [------] testuser 103.4G 0 0 00 [------]
Modify quota limits:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> limit isoft=500m ihard=700m user
xfs_quota> limit isoft=500m ihard=700m user
For example, to set a soft and hard inode count limit of 500 and 700 respectively for user
john
, whose home directory is/home/john
, use the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota -x -c 'limit isoft=500 ihard=700 john' /home/
# xfs_quota -x -c 'limit isoft=500 ihard=700 john' /home/
In this case, pass
mount_point
which is the mounted xfs file system.Display the expert commands available with
xfs_quota -x
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> help
xfs_quota> help
Verification
Verify that the quota limits have been modified:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota> report -i -u User quota on /home (/dev/loop0) Inodes User ID Used Soft Hard Warn/ Grace ---------- -------------------------------------------------- root 3 0 0 00 [------] testuser 2 500 700 00 [------]
xfs_quota> report -i -u User quota on /home (/dev/loop0) Inodes User ID Used Soft Hard Warn/ Grace ---------- -------------------------------------------------- root 3 0 0 00 [------] testuser 2 500 700 00 [------]
Additional resources
-
xfs_quota(8)
man page on your system
23.7. Setting project limits for XFS
Configure limits for project-controlled directories.
Procedure
Add the project-controlled directories to
/etc/projects
. For example, the following adds the/var/log
path with a unique ID of 11 to/etc/projects
. Your project ID can be any numerical value mapped to your project.Copy to Clipboard Copied! Toggle word wrap Toggle overflow echo 11:/var/log >> /etc/projects
# echo 11:/var/log >> /etc/projects
Add project names to
/etc/projid
to map project IDs to project names. For example, the following associates a project calledlogfiles
with the project ID of 11 as defined in the previous step.Copy to Clipboard Copied! Toggle word wrap Toggle overflow echo logfiles:11 >> /etc/projid
# echo logfiles:11 >> /etc/projid
Initialize the project directory. For example, the following initializes the project directory
/var
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota -x -c 'project -s logfiles' /var
# xfs_quota -x -c 'project -s logfiles' /var
Configure quotas for projects with initialized directories:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow xfs_quota -x -c 'limit -p bhard=1g logfiles' /var
# xfs_quota -x -c 'limit -p bhard=1g logfiles' /var
Additional resources
-
xfs_quota(8)
,projid(5)
, andprojects(5)
man pages on your system