This chapter discusses the following:
For more information, see the xfs_quota(8) man pages.
If your system is constantly short of disk space and you cannot increase the amount of available space, you an use disk quotas to manage your existing space.
Disk quotas let you limit the amount of space a user can occupy and the number of files (inodes) each user can own. You can implement hard or soft limits; hard limits are enforced by the system, soft limits merely remind the user to trim disk usage. Disk usage limits are not enforced for root.
With soft limits, whenever a user logs in with a usage greater than the assigned soft limit, that user is warned (by the login command). When the user exceeds the soft limit, the timer is enabled. Any time the quota drops below the soft limits, the timer is disabled. If the timer is enabled longer than a time period set by the system administrator, the particular limit that has been exceeded is treated as if the hard limit has been reached, and no more disk space is allocated to the user. The only way to reset this condition is to reduce usage below the quota. Only root may set the time limits, and this is done on a per-filesystem basis.
You can impose limits on some users and not others, some filesystems and not others, and on total disk usage per user, or total number of files. There is no limit to the number of accounts and there is little performance penalty for large numbers of users.
You can also impose limits according to user ID, group ID, or project ID. You can associate a directory in the filesystem hierarchy with a project ID by including it in the /etc/projects file. (You can use /etc/projid to map each project name to its number.) With project quotas in effect, such a directory and all files and directories below it can be subjected to a quota, meaning that the aggregate resource used thereunder is limited. For more information, see the xfs_quota(8) man page.
Note: Group quotas and project quotas are mutually exclusive per filesystem because XFS records either the project ID or the group ID of a file in the same physical location; how the number is interpreted depends upon whether project or group quotas are in force. |
Disk quotas can be used to do disk usage accounting. Disk usage accounting monitors disk usage, but does not enforce disk usage limits. See “Monitoring Disk Space Usage with Quota Accounting ” for more information.
You must first turn on disk quotas on a filesystem, then you can set quotas on that filesystem for individual users and for projects or groups.
For more details about disk quotas, see the quotas(4) man page.
This section discusses the following:
You can enable quotas for users in these ways:
To turn on disk quotas automatically for users on a non-root filesystem, include the option quota in the /etc/fstab entry, for example:
/dev/foo / xfs rw,quota 0 0 |
To turn on disk quotas manually for users on a non-root filesystem, mount the filesystem with this command:
# mount -o quota fsname rootdir |
fsname is the device name of the filesystem, rootdir is the directory where the filesystem is mounted.
To turn on disk quotas for users on the root filesystem, you must pass the quota mount options into the kernel at boot time through the Linux rootflags boot option. The following example adds the rootflags=quota option to the append line in elilo.conf:
append="root=/dev/xscsi/pci00.01.0-1/tsrget0/lun0/part3 rootflags=quota" |
You can enable quotas for groups in these ways:
To turn on disk quotas automatically for groups on a non-root filesystem, include the option gquota in the /etc/fstab entry, for example:
/dev/foo / xfs rw,gquota 0 0 |
To turn on disk quotas manually for groups on a non-root filesystem, mount the filesystem with this command:
# mount -o gquota fsname rootdir |
fsname is the device name of the filesystem, rootdir is the directory where the filesystem is mounted.
To turn on disk quotas for groups on the root filesystem, you must pass the quota mount options into the kernel at boot time through the Linux rootflags boot option. The following example adds the rootflags=gquota option to the append line in elilo.conf:
append="root=/dev/xscsi/pci00.01.0-1/tsrget0/lun0/part3 rootflags=gquota" |
Note: Group and project quotas are mutually exclusive per filesystem. |
You can enable quotas for projects in these ways:
To turn on disk quotas automatically for projects on a non-root filesystem, include the option prjquota in the /etc/fstab entry, for example:
/dev/foo / xfs rw,prjquota 0 0 |
To turn on disk quotas manually for projects on a non-root filesystem, mount the filesystem with this command:
# mount -o prjquota fsname rootdir |
fsname is the device name of the filesystem, rootdir is the directory where the filesystem is mounted.
To turn on disk quotas for projects on the root filesystem, you must pass the quota mount options into the kernel at boot time through the Linux rootflags boot option. The following example adds the rootflags=prjquota option to the append line in elilo.conf:
append="root=/dev/xscsi/pci00.01.0-1/tsrget0/lun0/part3 rootflags=prjquota" |
After enabling quotas, you can set limits for users, groups, or projects:
After completing “Enabling Quotas for Users”, do the following to specify quota limits for a user:
# xfs_quota -x -c 'limit -u bsoft=N bhard=N user' rootdir |
where:
N is a soft or hard limit for disk usage in blocks of the specified unit: k (kilobytes), m (megabytes), g (gigabytes), or t (terabytes)
user is a user name or numeric user ID
rootdir is the mount point of the XFS filesystem.
For example, to set limits for user userA on /mnt/myxfs using a soft limit of 5 Mbytes and a hard limit of 6 Mbytes:
# xfs_quota -x -c 'limit -u bsoft=5m bhard=6m userA' /mnt/myxfs |
After completing “Enabling Quotas for Groups”, setting disk quota limits for groups is similar to setting limits for users (as described in “Setting Quota Limits for Users”), but uses the -g option and the group name or ID.
To specify quota limits for a group:
# xfs_quota -x -c 'limit -g bsoft=N bhard=N group' rootdir |
where:
N is a soft or hard limit for disk usage in blocks of the specified unit: k (kilobytes), m (megabytes), g (gigabytes), or t (terabytes)
group is a group name or numeric group ID
rootdir is the mount point of the XFS filesystem.
For example, to set limits for group groupA on /mnt/myxfs using a soft limit of 5 Mbytes and a hard limit of 6 Mbytes:
# xfs_quota -x -c 'limit -g bsoft=5m bhard=6m groupA' /mnt/myxfs |
After completing “Enabling Quotas for Projects”, setting limits for projects is similar to setting limits for groups (as described in “Setting Quota Limits for Groups”), but uses the -p option and the project name or ID.
Note: Group and project quotas are mutually exclusive per filesystem. |
To specify quota limits for a project:
# xfs_quota -x -c 'limit -p bsoft=N bhard=N project' rootdir |
where:
N is a soft or hard limit for disk usage in blocks of the specified unit: k (kilobytes), m (megabytes), g (gigabytes), or t (terabytes)
project is a project name or numeric group ID
rootdir is the mount point of the XFS filesystem.
For example, to set limits for project projectA on /mnt/myxfs using a soft limit of 5 Mbytes and a hard limit of 6 Mbytes:
# xfs_quota -x -c 'limit -p bsoft=5m bhard=6m projectA' /mnt/myxfs |
For more information about projects, see the xfs_quota(8) man page.
Some commands that display information about disk quotas are as follows:
To display a report that shows whether disk quotas are on or off for each filesystem:
# xfs_quota -x -c state |
To see filesystem quota information for a specific filesystem:
# xfs_quota -x -c report rootdir |
For example, to see quota information for the /mnt/myxfs filesystem:
# xfs_quota -x -c report /mnt/myxfs |
To get information about group disk quotas for each filesystem:
# xfs_quota -x -c 'report -g' |
If the filesystem being dumped contains quotas, xfsdump will use xfs_quota(8) to store the quotas in the following files in the root of the filesystem to be dumped:
These files will then be included in the dump. These files will appear only for those quotas that are enabled on the filesystem being dumped. Upon restoration, you can use xfs_quota to reactivate the quotas for the filesystem.
Note: The xfsdump_quotas file will probably require modification to change the filesystem or UIDs if the filesystem has been restored to a different partition or system. |
To create quota reports, do the following:
To create a file that lists the current quota limits of all the filesystems for users, enter this command as superuser:
# xfs_quota -x -c 'report -f quotafile' |
To create a file that lists the current quota limits of all the filesystems for groups, enter this command as superuser:
# xfs_quota -x -c 'report -g -f quotafile' |
The disk quotas system can be used to monitor disk space usage without enforcing disk usage limits. Disk quota accounting can be enabled by user or by group.
Use the following commands to turn on disk usage accounting without enforcement, stop disk usage accounting, and report disk space usage:
To turn on disk usage accounting automatically on a filesystem for user quotas, include the option qnoenforce in the /etc/fstab entry:
/dev/foo / xfs rw,qnoenforce 0 0 |
To turn on disk usage accounting automatically on a filesystem for group quotas, include the option gqnoenforce in the /etc/fstab entry:
/dev/foo / xfs rw, gqnoenforce 0 0 |
To turn on disk usage accounting manually for user quotas on a non-root filesystem, when mounting the filesystem:
# mount -o qnoenforce fsname rootdir |
fsname is the device name of the filesystem, rootdir is the directory where the filesystem is mounted.
To turn on disk usage accounting manually on a non-root filesystem for group quotas when mounting the filesystem:
# mount -o gqnoenforce fsname rootdir |
To turn on disk usage accounting manually on the root filesystem for user quotas, execute the following commands. The quotaon command turns on disk accounting with enforcement, and the quotaoff -o command turns off the enforcement:
# quotaon -v / # quotaoff -v -o enforce / # reboot |
To turn on disk usage accounting manually on the root filesystem (/) for group quotas:
# quotaon -v -o gquota / # quotaoff -v -o gqenforce / # reboot |
To stop disk usage accounting on a filesystem for user quotas:
# quotaoff fsname |
To stop disk usage accounting on a filesystem for group quotas:
# quotaoff -o gquota fsname |
To get information about disk usage, use the commands described in “Checking Disk Space Usage”.
The quota command reports the amount of disk usage per user, per group, or per project on a filesystem, as well as additional information about the disk quotas. You must turn on quotas to use this feature, even if you are not going to enforce quota limits. For instructions on monitoring disk space usage without enforcing disk usage limits see “Monitoring Disk Space Usage with Quota Accounting ”.
For information on the output of the quota command, see “Displaying Quota Information”.