• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Enable Disk Quotas on an XFS File System

by admin

XFS supports disk quotas by user, by group, and by project. Project disk quotas allow you to limit the amount of disk space on individual directory hierarchies. You can configure both hard and soft limits on the number of disk blocks (or disk space), and the number of inodes, which limit the number of files a user can create. Quotas do not apply to the root user.

You must first enable quotas for users, groups, and/or projects by using a mount option when mounting for the XFS file system. After enabling quotas, use the xfs_quota command to set limits, to view quota information.

Enabling Quotas

To enable quotas for users on an XFS file system, include the quota option in the /etc/fstab entry for the file system, or mount the file system with the quota option:

# mount –o quota /dev/xvdb1 /xfs

To enable quotas for groups, include the gquota option in the /etc/fstab entry for the file system, or mount the file system with the gquota option:

# mount –o gquota /dev/xvdb1 /xfs

To enable quotas for projects, include the prjquota option in the /etc/fstab entry for the file system, or mount the file system with the prjquota option:

# mount –o prjquota /dev/xvdb1 /xfs

Alternatively, you can 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:

# 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

XFS Quota Mount Options

Other “quota” mount options for XFS file systems are available. The following is a complete list of mount options to enable user quotas on XFS file systems:

  • quota|uquota|usrquota: Enable user quotas and enforce usage limits.
  • uqnoenforce: Enable user quotas. Report usage but do not enforce usage limits.

Group quota mount options include the following:

  • gquota|grpquota: Enable group quotas and enforce usage limits.
  • gqnoenforce: Enable group quotas. Report usage but do not enforce usage limits.

Project quota mount options include the following:

  • pquota|prjquota: Enable project quotas and enforce usage limits.
  • pqnoenforce: Enable project quotas. Report usage but do not enforce usage limits.

Report Quota State Information

You can use the following xfs_quota command to report the overall quota state information:

# xfs_quota -x -c state
User quota state on /data (/dev/mapper/vg_test-lv_test)
  Accounting: ON
  Enforcement: ON
  Inode: #67 (1 blocks, 1 extents)
Group quota state on /data (/dev/mapper/vg_test-lv_test)
  Accounting: OFF
  Enforcement: OFF
  Inode: #0 (0 blocks, 0 extents)
Project quota state on /data (/dev/mapper/vg_test-lv_test)
  Accounting: OFF
  Enforcement: OFF
  Inode: #0 (0 blocks, 0 extents)
Blocks grace time: [7 days]
Inodes grace time: [7 days]
Realtime Blocks grace time: [7 days]

This command reports whether user, group, and project disk quota accounting is enabled and whether limits are being enforced. The grace period for blocks and inodes is also reported. The timer for the grace period is enabled whenever the soft limit is exceeded. If soft limits continue to be exceeded after the grace period expires, no more disk space or inodes are allocated.

xfs_quota Utility

After enabling quotas by using XFS file system mount options, use the xfs_quota command to report file system quota information, set block and inode limits, enable or disable quota enforcement, modify the quota enforcement timeout information (grace period), and perform other quota management operations on XFS file systems.

The xfs_quota utility provides a number of user and administrator subcommands. These subcommands can be issued in interactive mode or included as arguments to the xfs_quota command. Enter xfs_quota without any options or arguments to enter interactive mode. An xfs_quota> prompt appears in interactive mode. Enter help or ? to view the available subcommands. You can also enter help commandname to display additional information on a specific subcommand.

# xfs_quota 
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] [-g|-p|-u] [-hnNv] [-f file] [id|name]... -- show usage and limits

Use 'help commandname' for extended help.

When including xfs_quota subcommands from the command line, use the –c [command] option. Any modifications to the quota system from the command line also require the -x option (enable expert mode). The following example uses the limit subcommand to set a soft limit of 5 MB, and a hard limit of 6 MB on the XFS file system for user john:

# xfs_quota –x –c 'limit –u bsoft=5m bhard=6m john' /xfs

The following example sets a soft limit of 100 inodes and a hard limit of 150 inodes for the students group:

# xfs_quota –x –c 'limit –g isoft=100 ihard=150 students' /xfs

Displaying Quota Information

Use the xfs_quota command to display information about disk quotas. To list all paths with devices and identifiers:

# xfs_quota -x -c print
Filesystem          Pathname
/data               /dev/mapper/vg_test-lv_test (uquota)

To report file system usage for blocks (-b) and inodes (-i):

# xfs_quota -x -c 'free -hb'
Filesystem                     Size    Used    Avail   Use%   Pathname
/dev/mapper/vg_test-lv_test    35.5G   41.1M   35.4G   0%     /data
# xfs_quota -x -c 'free -hi'
Filesystem                     Inodes   Used   Free     Use%   Pathname
/dev/mapper/vg_test-lv_test    18.6m    5      18.6m    0%     /data

To report file system quota information:

# xfs_quota -x -c report /data
User quota on /data (/dev/mapper/vg_test-lv_test)
                               Blocks                     
User ID          Used       Soft       Hard    Warn/Grace     
---------- -------------------------------------------------- 
root                4          0          0     00 [--------]

To report quota information in human-readable form on /data:

# xfs_quota -x -c 'report -h' /data
User quota on /data (/dev/mapper/vg_test-lv_test)
                        Blocks              
User ID      Used   Soft   Hard Warn/Grace   
---------- --------------------------------- 
root           4K      0      0  00 [------]

Setting Project Quotas

XFS allows you to set quotas on individual directory hierarchies. You can create an entry in the /etc/projects file that associates the XFS file system directory hierarchy with a unique project ID. For example, the following entry in /etc/projects associates a project ID of 50 with the /data directory:

50:/data

You can optionally use the /etc/projid file to associate a project name to a project ID. For example, the following entry in the /etc/projid file associates the project name test with the project ID 50:

test:50

After defining a project in /etc/projects, use the xfs_quota command to initialize its project directory:

# xfs_quota –x –c 'project –s test' /data

Use the xfs_quota command to set limits for projects with initialized directories. The following example sets a soft limit of 5 MB and a hard limit of 6 MB for the test project:

# xfs_quota –x –c ‘limit –p bsoft=5m bhard=6m test’ /data
How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)
Running repairs on XFS Filesystems
How to grow/extend XFS filesytem in CentOS / RHEL using “xfs_growfs” command

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to take mailbox backup of Zimbra Account from CLI
  2. atop Command Examples in Linux
  3. Understanding Device Persistence and Oracle ASMLib
  4. lolcat: command not found
  5. Linux “rm” Command Examples
  6. CentOS / RHEL 5 : How to install and configure vsftpd server
  7. pluma Command Examples in Linux
  8. qjoypad Command Examples in Linux
  9. Image optimization with webp
  10. createrepo Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright