Hard disk quotas are limits placed on users or groups
Soft limits are disk usage limits that can be exceeded for only a set period of time (usually sevel days).
Hard limits are just that – users/groups simply cannot exceed these disk usage settings.
Limits on the number of blocks (remember, blocks are typically 1 Kilobyte) and the number of inodes (which means, numbers of files – and don’t forget that directories are files) can be placed on either users or groups.
Disk quotas are not enabled by default.
You must enable them by adding usrquota to the mount entry in the /etc/fstab file:
/dev/hda1 / ext2 defaults,usrquota,grpquota 1 2
Then the system must be rebooted, or the partition can be remounted:
mount / -o remount,rw
Create aquota.user and aquota.group files using:
touch /aquota.group /aquota.user
Create a disk usage table for the affected partition (in this case, hda1):
quotacheck –mavug /
-m – update even if filesystem is in use by other processes
-a – for all filesystems with usrquota or grpquota specified
-v – verbose
-u – turn on user quotas
-g – turn on group quotas
This is really simple. Use quotaon with the filesystem as its argument:
quotaon /
You can also turn quotas off:
quotaoff /
Now you’ll be glad you’re familiar with vi. Command:
edquota -u username
Voila – you’re in vi, where you can change a text file to set soft and hard limits for blocks and inodes:
Disk quotas for user glenn (uid500):
Filesystem _ blocks _ soft _ hard _ inodes _ soft _ hard
/_________ 1000 ___ 0____ 0 ___ 400 ___ 0 ___ 0Soft or hard limits of 0 mean no limits.
“Filesystem” means just that: the mounted filesystem by name, for instance / .
“Blocks” means blocks currently used by this user.
The first “soft” is the column where soft block limits can be set.
The first “hard” is the hard block limit.
“Inodes” means inodes currently in use by this user.
The second “soft” is the soft inode limit for this user.
The second “hard” is the hard inode limit.Use:
edquota -g groupname
to modify settings for groups.
Edit the default time limit for users exceeding their soft quotas
Use the command:
edquota -u -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
__/___________7days____________7days
For example:
# Check quota and then turn quota on.
if [ -x /sbin/quotacheck ]
then
echo “Checking quotas. This may take some time.”
/sbin/quotacheck -avug
echo ” Done.”
fi
if [ -x /sbin/quotaon ]
then
echo “Turning on quota.”
/sbin/quotaon -mavug
fiThis script will be /etc/init.d/quota.
Turn on the quota script upon boot
Issue the commands:
chmod 755 /etc/init.d/quota
chkconfig on quota
Periodically use the
quotacheck
command to keep users’ and groups’ disk usage limits current.
This command checks and enforces quota limits.
Add this line to your crontab file to run quotacheck weekly:
0 3 * * 0 /sbin/quotacheck -avug
Use the
repquota -a
command to read quota data for all users and groups.
Use du to check on specific users’ usage.
Issue:
du –h –c –s /home/user1 /home/user2 /home/user3
This is a handy command to run from cron and pipe to mail to the system admin.