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:
- There is a limited amount of disk space that must be shared between many people.
- Some people tend to use much more disk space than they need, and far beyond what is reasonable and fair for a shared resource.
- Sometimes processes can go out of control and produce huge amounts of data. If a disk fills up, no more data will be able to be saved, and people will lose work; for instance, someone who has been working with an editor may not be able to save their changes.
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.
[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.
- A block quota is the limit on the actual amount of disk space that can be used by an account. This space is measured in 1 KB blocks (1 KB = 1024 bytes or characters). All files, directories, etc., use up some number of blocks.
- A file quota is the limit on the number of files, directories, etc., that there can be for an account. This is because each file system (eg, /home/home1/) has a finite sized inode table, and each file system object (such as a file or directory) uses up one inode. When this table gets filled up, no more files can be created.
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'').
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:
- If you do not want this warning service, you can disable it by creating a file in your home directory named .no_quota_check.
- You can alter the reporting threshold and who the warning e-mail will be sent to by creating a file in your home directory named .quota_check with lines like:
threshold = 85 mailto = email@example.com
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.