In a large working group, especially people share a cluster environment, sooner or later, you will have to face the computing fair share and quota problem. Same to disk.

The XFS quota subsystem manages limits on disk space (blocks) and file (inode) usage. it controls or reports on usage of these items on a user, group, or directory or project level. Also, note that while user, group, and directory or project quotas are enabled independently, group and project quotas are mutually exclusive.

When managing on a per-directory or per-project basis, XFS manages the disk usage of directory hierarchies associated with a specific project. In doing so, XFS recognizes cross-organizational " group" boundaries between projects. This provides a level of control that is broader than what is available when managing quotas for users or groups.

Enable XFS File System quota

XFS quotas are enabled at mount time, with specific mount options. Each mount option can also be specified as no enforce; this will allow usage reporting without enforcing any limits. Valid quota mount options are:

uquota/uqnoenforce - User quotas
gquota/gqnoenforce - Group quotas
pquota/pqnoenforce - Project quota


 mount -o uquota /dev/mapper/LUN13 /lun13

XFS File System quota interactive sub command options

Once quotas are enabled, the xfs_quota tool can be used to set limits and report on disk usage. By default, xfs_quota is run interactively, and in basic mode. Basic mode sub-commands simply report usage, and are available to all users. Basic xfs_quota sub-commands include:
quota username/userID

    Show usage and limits for the given username or numeric userID
d f
    Shows free and used counts for blocks and inodes.

Here is the full list of sub command and their usage

# xfs_quota  /lun13
xfs_quota> help
df [-bir] [-hn] [-f file] -- show free and used counts for blocks and inodes
help [command] -- help for one or all commands
print -- list known mount points and projects
quit -- exit the program
quota [-bir] [-gpu] [-hnNv] [-f file] [id|name]... -- show usage and limits

Use 'help commandname' for extended help.
xfs_quota> print
Filesystem          Pathname
/lun13      /dev/mapper/LUN13 (uquota)
xfs_quota> help quota
quota [-bir] [-gpu] [-hnNv] [-f file] [id|name]... -- show usage and limits

 display usage and quota information

 -g -- display group quota information
 -p -- display project quota information
 -u -- display user quota information
 -b -- display number of blocks used
 -i -- display number of inodes used
 -r -- display number of realtime blocks used
 -h -- report in a human-readable format
 -n -- skip identifier-to-name translations, just report IDs
 -N -- suppress the initial header
 -v -- increase verbosity in reporting (also dumps zero values)
 -f -- send output to a file
 The (optional) user/group/project can be specified either by name or by
 number (i.e. uid/gid/projid).

XFS xfs_quota expert mode

In contrast, xfs_quota also has an expert mode. The sub-commands of this mode allow actual configuration of limits, and are available only to users with elevated privileges. To use expert mode sub-commands interactively, run xfs_quota -x. Expert mode sub-commands include:


Reports quota information for a specific file system.


Modify quota limits.

How to set XFS quota

For a complete list of sub-commands for either basic or expert mode, use the sub-command help. All sub-commands can also be run directly from a command line using the -c option, with -x for expert sub-commands.

# xfs_quota -x -c 'limit isoft=500 ihard=700 trteam' /lun13

By default, the limit sub-command recognizes targets as users. When configuring the limits for a group, use the -g option (as in the previous example). Similarly, use -p for projects.

Soft and hard block limits can also be configured using bsoft or bhard instead of isoft or ihard .
To set a soft and hard block limit of 1000m and 1200m, respectively, to group
accounting on the /target/path file system, use the following command:

# xfs_quota -x -c ' limit -g bsoft= 1000 m bhard = 1200m test ' /lun13

The commands bsoft and bhard count by the byte. And, to be able set quota for group/project, you need enable gquota/pquota when mounting the XFS File System.

How to display quota report

For example, to display a sample quota report for /lun13 (on /dev/mapper/lun13), use the command

xfs_quota -x -c 'report -bih' /lun13
User quota on /lun13 (/dev/mapper/LUN13)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- ---------------------------------
root            0      0      0  00 [------]      3      0      0  00 [------]
test       10.3M  1000M   1.2G  00 [------]     15    500    700  00 [------]

While real-time blocks (rtbhard /rtbso ft) are described in man xfs_q uo ta as valid units when setting quotas, the real-time sub-volume is not enabled in this release. As such, the rtbhard and rtbso ft options are not applicable.

Setting Project quota Limits

Before configuring limits for project-controlled directories, add them first to /etc/pro jects. Project names can be added to /etc/pro jecti d to map project ID s to project names. Once a project is added to /etc/pro jects, initialize its project directory using the following command:

# xfs_quota -x -c ' project -s projectname' project_path

Quotas for projects with initialized directories can then be configured, with:

# xfs_quota -x -c ' limit -p bsoft= 1000m bhard = 1200m projectname'

Generic quota configuration tools (quota, repquota, and edquota for example) may also be used to  manipulate XFS quotas. However, these tools cannot be used with XFS project quotas.

Red Hat recommends the use of xfs_quota over all other available tools.

Comments powered by CComment