Saturday, August 14, 2010

Disk Quotas in Linux


Here is the simple quick guide to setup disk quotas in Linux. Please post your comments
 Uses of Disk quotas:
  1. Limits disk usage (blocks or inodes)
  2. Tied to file systems (set on a per file system basis)
  3. Can be configured for users and groups

Steps to enable quota support:
 1. Enable quota support per file system in: /etc/fstab
  Add  defaults,usrquota,grpquota in end of the line for the file system you want enable quota
 2. Remount the file system(s)
  a. mount -o remount /
  b. use 'mount' to confirm that 'usrquota,grpquota' support are enabled
 3. Create quota database files and generate disk usage table
  a. quotacheck -mcug / - this creates /aquota.user & /aquota.group
  b. quotacheck -mavug
 4. Assign quota policies
  a. edquota username - set blocks/inodes soft_limits hard_limit
     edquota student1 - sets quotas for user 'student1'
     export EDITOR=nano - to have edquota default to 'nano' editor
5. Check quotas
  a. quota username
     quota student1 
Note: place 'quotacheck -avug' in /etc/cron.*(hourly,daily) 
6. Report on usage
  a. repquota -a - this reports on usage
 Note: The blocks are measured in 1K increments. i.e. 20000 blocks is roughly 20MB