17.2. Managing Disk Quotas
If quotas are implemented, they need some maintenance mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate.
If users repeatedly exceed their quotas or consistently reach their soft limits, a system administrator has a few choices to make depending on what type of users they are and how much disk space impacts their work. The administrator can either help the user determine how to use less disk space or increase the user's disk quota.
17.2.1. Enabling and Disabling
It is possible to disable quotas without setting them to 0. To turn all user and group quotas off, use the following command:
#
quotaoff -vaug
If neither the
-u
or -g
options are specified, only the user quotas are disabled. If only -g
is specified, only group quotas are disabled. The -v
switch causes verbose status information to display as the command executes.
To enable user and group quotas again, use the following command:
#
quotaon
To enable user and group quotas for all file systems, use the following command:
#
quotaon -vaug
If neither the
-u
or -g
options are specified, only the user quotas are enabled. If only -g
is specified, only group quotas are enabled.
To enable quotas for a specific file system, such as
/home
, use the following command:
#
quotaon -vug /home
Note
The
quotaon
command is not always needed for XFS because it is performed automatically at mount time. Refer to the man page quotaon(8)
for more information.
17.2.2. Reporting on Disk Quotas
Creating a disk usage report entails running the
repquota
utility.
Example 17.6. Output of the repquota
Command
For example, the command
repquota /home
produces this output:
*** Report for user quotas on device /dev/mapper/VolGroup00-LogVol02 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 36 0 0 4 0 0 kristin -- 540 0 0 125 0 0 testuser -- 440400 500000 550000 37418 0 0
To view the disk usage report for all (option
-a
) quota-enabled file systems, use the command:
# repquota -a
While the report is easy to read, a few points should be explained. The
--
displayed after each user is a quick way to determine whether the block or inode limits have been exceeded. If either soft limit is exceeded, a +
appears in place of the corresponding -
; the first -
represents the block limit, and the second represents the inode limit.
The
grace
columns are normally blank. If a soft limit has been exceeded, the column contains a time specification equal to the amount of time remaining on the grace period. If the grace period has expired, none
appears in its place.
17.2.3. Keeping Quotas Accurate
When a file system fails to unmount cleanly, for example due to a system crash, it is necessary to run the following command:
#
quotacheck
However,
quotacheck
can be run on a regular basis, even if the system has not crashed. Safe methods for periodically running quotacheck
include:
- Ensuring quotacheck runs on next reboot
Note
This method works best for (busy) multiuser systems which are periodically rebooted.Save a shell script into the/etc/cron.daily/
or/etc/cron.weekly/
directory or schedule one using the following command:#
crontab -e
Thecrontab -e
command contains thetouch /forcequotacheck
command. This creates an emptyforcequotacheck
file in the root directory, which the system init script looks for at boot time. If it is found, the init script runsquotacheck
. Afterward, the init script removes the/forcequotacheck
file; thus, scheduling this file to be created periodically withcron
ensures thatquotacheck
is run during the next reboot.For more information aboutcron
, seeman cron
.- Running quotacheck in single user mode
- An alternative way to safely run
quotacheck
is to boot the system into single-user mode to prevent the possibility of data corruption in quota files and run the following commands:#
quotaoff -vug /file_system
#
quotacheck -vug /file_system
#
quotaon -vug /file_system
- Running quotacheck on a running system
- If necessary, it is possible to run
quotacheck
on a machine during a time when no users are logged in, and thus have no open files on the file system being checked. Run the commandquotacheck -vug file_system
; this command will fail ifquotacheck
cannot remount the given file_system as read-only. Note that, following the check, the file system will be remounted read-write.Warning
Runningquotacheck
on a live file system mounted read-write is not recommended due to the possibility of quota file corruption.
See
man cron
for more information about configuring cron
.