Help File Library: Using Quota
Written By:
Ralph Bagaipo
Edquota 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 or per group, 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.
This may help to some that wants to limit their users. What I have done
in my system may help you too. Here it is.
HOW-TO use Edquota to limit your users disk-space/email.
1. First of all, you have to check if your kernel supports quota. And
configure if it doesnt.(check the kernel how-to for
it.). But on default install, its enabled (for most systems).
2. Then slap this to your /etc/rc.local or to
wherever you put your startfile. This should be done at boot time in order
for the filesystem to enable quota support.
------------------------
# Check quota and then turn
quota on.
if [ -x /usr/sbin/quotacheck
]
then
echo"Checking quotas. This may take some time."
/usr/sbin/quotacheck -avug
echo " Done."
fi
if [ -x /usr/sbin/quotaon ]
then
echo "Turning on quota."
/usr/sbin/quotaon -avug
fi
fi
------------------------
3. Next, you should enable which partition you want quota to take effect.
Usually this would be /home. And sometimes, on where your emails are
stored (/var/spool/mail). Say, /home is in /dev/hda1. then you should
modify your /etc/fstab. It should be like this. (usrquota=userquota,
grpquota=groupquota). Userquota and Groupquota is explained below.
------------------------
/dev/hda1
/home
ext2
defaults,usrquota,grpquota
1 1
4. next, you should create a file name
quota.user
and quota.group to the directory where you enabled quotas on. In
this
case, the /home directory.
# touch
/home/quota.user
# touch
/home/quota.group
# chmod 600
/home/quota.user
# chmod 600
/home/quota.group
5. REBOOT. on boot up, you should see
something like Checking quotas. This may take some time. And Turning quota
on.
6. You are ready to administer quotas.
7. Now, there are two ways to administer your users. Either by-user or
by-group. Lets say you have the group users. you can edit quotas
for group users by executing the command: (-g ; switch for
edquota to edit group quotas)
#edquota -g users
or for user flar,
# edquota -u flar
(-u ; switch for edquota to edit user quotas)
and that opens quota editor on its default editor which is vi. if
you want to change the default editor to other editors, say, pico(or
whatever you used), then you just have to execute this before issuing
edquota.
# export EDITOR=pico
# edquota -g users
and you should see a file with lines like this;
------------------------
Quotas for group users:
/dev/hda1 blocks in use: 255924, limits (soft = 0, hard =0)
inodes in use: 990, limits (soft = 0, hard = 0)
------------------------
If you see, there are data inside the parenthesis. Namely soft
and hard.
In this portion now, I should explain Soft, Hard and
Grace. By the way, these are limits.
-
Soft indicates the maximum amount of disk usage a quota user has on
the specified partition.
-
Hard specifies the absolute limit on the disk usage but only when
grace period is set.
-
Grace is a time limit before the soft limit is enforced for a file
system with quota enabled. and is performed with the command edquota
-t. and it would look like this;
------------------------
Time units may be: days, hours, minutes, or seconds
Grace period before enforcing soft limits for
users:
/dev/hda1: block grace period: 7 days, file grace
period: 7 days
------------------------
I'll explain the last line. 7 days is usually the default (in my case).
You could change it to how many hours, minutes or seconds the hard limit
or soft limit be enforced. Which means, that after 7 days, it should
locked-up the usage of the user.
After those, you could see what youve done by issuing the command
repquota -a. and you should see lines like these.
------------------------
# 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
flar
--
13046 10000
10000
806 0
0
you
-- 2838
5120
6400
377
0 0
------------------------
8. Thats it!! All should be workin fine. Take a milk
or beer and congratulate yourself for a job well done :o)
Note: If you're using Qmail and it's Maildir support, then it should
be easy to administer the users Disk-space and Mailboxes right? Because
its files and e-mails are on one directory :o) so you will just configure
/home directory for your quota administration.