Disk quota

From ArchWiki
Revision as of 15:56, 27 April 2006 by Peq (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

After starting administrating the network on a little school, I did learn quite a lot about Linux. Here´s some of it.

Installing Quota-tools

This is a little howto setup Userquota on a Arch Linux. first of alle you need a full functionel Arch linux machine. Afterwards we need to get the package quota-tools.

$ pacman -Sy quota-tools


now we got the things we need. and are ready for the configuration. First we need to edit /etc/fstab - thats where we decide wich mounts we need to make a quota on. let say we have a special harddrive thats mounted in /home - the line in /etc/fstab looks like this:

/dev/hdb1 /home ext3 defaults 1 1

we need to edit it to this

/dev/hdb1 /home ext3 defaults,usrquota 1 1
That´s it here, so the next part is to start quota and make it index the files.
$ mount -v -o remount /home    <-- to remount home
$ quotacheck -a -m             <-- to make an index over the files 
$ quotaon -uv /home            <-- start quota

the last line kan answer with this error - the kernel does not support quota - you need to recompile it ?? I did a reboot and everything works afterwards. (You can change /home to -a in the last line, then it startet on all devices )

quotaon must be run everytime the machine starts, so its a good idea to make a startscript or put it into rc.local

The user quotes

Now we shall setup how much the users quantum of space ant that´s where we use this command

$ edquota -u quotauser
Disk quotas for user quotauser (uid 500):
Filesystem      blocks       soft       hard     inodes     soft   hard       
/dev/hda2       695879         0           0       6741        0      0

Here is the idea to make a testuser, then afterwards copy the files to all the users. The limits is here defined in kbytes - so that 10000 = 10MB. If the qoutas is not setup, the defaults is there´s no limits.we can also see that the user quotauser i this moment uses 695879filesblocks (679MB) and 6741files with no limits on. now edit the number so it looks like this:

Disk quotas for user quotauser (uid 500):
Filesystem      blocks       soft       hard     inodes     soft   hard       
/dev/hda2       695879       10000      15000     6741        0      0

this means that the user ALWAYS can use 10MB of space, and can be graced for a period for 5more. If you want to set the grace time, you can do it with:

$ 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/hda2        7 days                    7days

The trick about using a testuser, is that you really easy can copy the quota to all users on your system. Done by:

$ edquota -p quotauser `awk -F: '$3 > 499 {print $1} /etc/passwd`

Here makes the same settings on all users with uid on 500 and above..

Other interesting kommands

There are sevarel interesting kommands, but here is some of them:

* repquota -a      <-- shows the status on diskusage
* warnquota        <-- can be used to warn the users about their quota
(warnquota sends mail to the users, is the files /etc/quotatab & /etc/warnquota.conf. These are use to make the messages more readable)

at last the quotastats is used to give info about the quota system:

$ quotastats
Number of dquot lookups: 101289
Number of dquot drops: 101271
Number of still active inodes with quota : 18
Number of dquot reads: 93
Number of dquot writes: 2077
Number of quotafile syncs: 134518740
Number of dquot cache hits: 7391
Number of allocated dquots: 90
Number of free dquots: 2036
Number of in use dquot entries (user/group): -1946

More info

Please be free to edit/add comments or corrections about this page.