Updated on Red Hat 9 on 17th June 2003
Quota allows you to specify limits on two aspects of disk storage: the number of inodes a user or a group of users may possess; and the number of disk blocks that may be allocated to a user or a group of users.
The idea behind quota is that users are forced to stay under their disk comsumption limit, taking away their ability to comsume unlimited disk space on a system. Quota is handled on a per user, per file system basis. If there is more than one file system which a user is expected to create files, then quota must be set for each file system seperately.
Partitions that you have not yet enabled quota normally look something like:
/dev/sda9 / ext3 defaults 1 1
/dev/sda7 /home ext3 defaults 1 2
/dev/sda8 /var ext3 defaults 1 2
To enable user quota support on a file system, add "usrquota" to the fourth field containing the word "defaults" (man fstab for details).
/dev/sda9 / ext3 defaults 1 1
/dev/sda7 /home ext3 defaults,usrquota 1 2
/dev/sda8 /var ext3 defaults,usrquota 1 2
# touch /home/aquota.user
# mount -o remount /home
# quotacheck -avugm
quotacheck: WARNING - Quotafile //aquota.user was probably truncated. Can't save quota settings...
quotacheck: Scanning /dev/sda7 [/] |
Here's an example. I have a user with the login id hoge on my system. The command "edquota -u username" takes you into vi to edit quota for user username on each partition that has quota enabled:
|
Disk quotas for user username (uid 500): |
In addition to edquota, there are 3 terms which you should familiarize yourself with: Soft Limit, Hard Limit, and Grace Period.
_Soft limit_ indicates the maximum amount of disk usage a quota user has on a partition. When combined with grace period, it acts as the border line, which a quota user is issued warnings about his impending quota violation when passed.
Hard limit works only when grace period is set. It specifies the absolute limit on the disk usage, which a quota user can't go beyond his hard limit.
Executed with the command "edquota -t", grace period is a time limit before the soft limit is enforced for a file system with quota enabled. Time units of sec(onds), min(utes), hour(s), day(s), week(s), and month(s) can be used. This is what you'll see with the command "edquota -t":
Grace period before enforcing soft limits for users:
Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/dev/sda7 7days 7days
Change the 0 days part to any length of time you feel reasonable. I personally would choose 7 days (or 1 week).
To rapidly set quotas for, say 100 users, on my system to the same value as my user hoge, I would first edit hoge's quota information by hand, then execute:
edquota -p hoge `awk -F: '$3 > 499 {print $1}' /etc/passwd`
assuming that you are using csh, and that you assign your user UID's starting with 500.
Quotacheck is used to scan a file system for disk usages, and updates the quota record file "quota.user" to the most recent state. I recommend running quotacheck at system bootup, or via cronjob periodically (say, every week?).
Repquota produces a summarized quota information for a file system. Here is a sample output repquota gives:
# repquota -a
Block limits File limits
User used soft hard grace used soft hard grace
root -- 175419 0 0 14679 0 0
bin -- 18000 0 0 735 0 0
uucp -- 729 0 0 23 0 0
man -- 57 0 0 10 0 0
user1 -- 13046 15360 19200 806 1500 2250
user2 -- 2838 5120 6400 377 1000 1500
/dev/sda5 /var ext2 defaults,usrquota 1 2
/dev/sda5: blocks in use: 0, limits (soft = 5000, hard = 6000)
inodes in use: 0, limits (soft = 0, hard = 0)
For example, apply same value to one group (UID > 499, GID = 501)
edquota -p modeluser `awk -F: '$3 > 499 && $4==501{print $1}' /etc/passwd`
Copyright © [- SroNey / JohN -]. All rights reserved