CSL: Understanding & Monitoring Your Disk Quota

CSL: Understanding & Monitoring Your Disk Quota

Why do we need disk quotas? Disk space is a finite and shared resource (even considering the enormous increases in hard-disk technology in recent years). Disk quotas are needed in home directory partitions for various reasons:

For these reasons and others, it is necessary for the CSL staff to manage home directory space. Disk quotas are an equitable way of doing this.

Getting and understanding information about your disk quota:

[Note: As of January 2002, the home filesystems have been moved to NetApp Filers. While providing increased performance and capacity, these do not currently support soft quotas in the same way as Solaris filesystems; we are working on a solution to this, so users will be notifed before they reach their quota and are unable to write any further files. Please be aware of this, so you do not accidentally lose any data.]

There are two types of quotas that are set on home directories via the UNIX disk quota system: block quotas and file quotas.

While it is not uncommon for someone to exhaust their blocks quota, it is quite unusual for anyone to use up their files quota.

The usual way to get information about the status of your quota is via the quota command. Here's some sample output:

user@login> quota -v
Disk quotas for user (uid 12345):
Filesystem     blocks quota  limit  grace  files  quota  limit   grace
minerva:/vol/vol0/insitu4
               105301 150000 187500        7860   30000  37500

The meanings of the numbers are as follows:

blocks The actual number of blocks used.
quota The quota for blocks; you willl start getting warnings when you exceed this amount.
limit The hard quota for blocks; you cannot exceed this limit under any circumstances.
grace The amount of time you have left to get back below your blocks soft quota before UNIX starts getting angry.
files The actual number of files (inodes) used.
quota The soft quota for files; you will start getting warnings when you exceed this amount.
limit The hard quota for files; you cannot exceed this limit under any circumstances.
grace The amount of time you have left to get back below your files soft quota before UNIX starts getting angry.

Remember to use the -v option with the quota command. See the quota man page for more information.

Note: As noted above, home directories are now on the NetApp Filer, where quotas work a little differently than they do on Solaris. On the Filer, there are only hard quotas; ie, the soft quota is the same as the hard quota (``limit'').

Automatic monitoring of your disk quota:

The CSL runs an automated program nightly that will send an e-mail notification to anyone whose home directory disk or file usage has exceeded some predetermined threshold percentage of their quota. You can modify this process for your account in various ways:

Customizable automatic monitoring of your disk quota:

For people who would like finer-grained control of the monitoring of their disk quota, the CSL provides a program that can be run by the user, and which can be automated through use of the standard UNIX cron utility. The program is called quota_check, and will give you easy to understand information about the status of your quota; cron will run the command automatically at set intervals.

A key feature of quota_check is the ability to set a usage threshold below which no report is produced. For instance, you can set a threshold of 80%, in which case the program will only notify you if your blocks or files usage has reached or exceeded 80% of your quota.

quota_check is set up to send its report via e-mail by default. This is because it was designed to be used from the cron utility. Thus it can be easily set up to notify you only when you have exceeded some threshold amount of your quota. Here's a sample crontab entry for doing this:

     0 0,8,12,16,20 * * * /home/lab/bin/quota_check -t 90

This line tells the cron utility to check your quota at midnight, 8am, noon, 4pm, and 8pm, and send you an e-mail report only if your blocks or files usage reaches 90% or more of your quota. Please see the crontab man page or the Crontabs FAQ page for more information.

Type /home/lab/bin/quota_check -h for a full list of the options that are available.

quota_check is a shell script. If you are familiar with shell programming, you can make your own copy and modify it any way you like. Or you can even write your own version from scratch. Please contact the Lab staff if you have any comments or suggestions.