Whole document tree
    

Whole document tree

Quota mini-HOWTO: Quota Setup on Linux - Part I: The Configuration Next Previous Contents

4. Quota Setup on Linux - Part I: The Configuration

4.1 Reconfigure your kernel

Reconfigure your kernel and add quota support by typing y to:


Quota support (CONFIG_QUOTA) [n] y

4.2 Compile and install the quota softwares

Most Linux distributions can help you installing the quota package. If not, or if you don't want to use this, you can download the latest version of the quota software source from


ftp://ftp.funet.fi/pub/Linux/tools/quota-1.31.tar.gz

Compile and install the quota software.

4.3 Modify your system init script to check quota and turn quota on at boot time

Here's an example:


# 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

The golden rule is that always turn quota on after your file systems in /etc/fstab have been mounted, otherwise quota will fail to work. I recommend turning quota on right after the part where file systems are mounted in your system init script.

4.4 Modify /etc/fstab

Partitions that you have not yet enabled quota normally look something like:


/dev/hda1       /       ext2    defaults        1       1
/dev/hda2       /usr    ext2    defaults        1       1

To enable user quota support on a file system, add "usrquota" to the fourth field containing the word "defaults" (man fstab for details).


/dev/hda1       /       ext2    defaults        1       1
/dev/hda2       /usr    ext2    defaults,usrquota       1       1

Replace "usrquota" with "grpquota", should you need group quota support on a file system.


/dev/hda1       /       ext2    defaults        1       1
/dev/hda2       /usr    ext2    defaults,grpquota       1       1

Need both user quota and group quota support on a file system?


/dev/hda1       /       ext2    defaults        1       1
/dev/hda2       /usr    ext2    defaults,usrquota,grpquota       1   1

4.5 Create quota record "quota.user" and "quota.group"

Both quota record files, quota.user and quota.group, should be owned by root, and read-write permission for root and none for anybody else.

Login as root. Go to the root of the partition you wish to enable quota, then create quota.user and quota.group by doing:


touch /partition/quota.{user,group} 
chmod 600 /partition/quota.{user,group} 

4.6 Activate the quota system

To activate the quota software you can reboot the system for the changes you have made to take effect.

A better alternative is to execute the system init script you just created. This will initialize the quota database. If you do a `ls -la /partition/quota.*` you will notice that the file sizes are no longer of size zero. This will tell you that quota is working.

Also note that subsequent partitions you wish to enable quota in the future only require step 4, 5, and 6.

Add quotacheck to crontab

Quotacheck should be running periodically, e.g. weekly. Add the following line to your root's crontab:


0 3 * * 0 /sbin/quotacheck -avug


Next Previous Contents