Disk Quotas Version 2, Linux 2.6

Šarunas Burdulis

Version 1.0, May 26, 2006


Contents

Introduction

One of the why we introduced disk quotas is to protect gauss:/home filesystem from being accidentally filled-up. Sometimes a user would dump the entire contents of an iPod or laptop hard disk into their home on gauss and this can easily result in ``disk full'' situation where users won't be able to receive e-mail or even log in. A dedicated partition gauss:/z is now provided for such a temporary storage.

Enabling disk quotas

Support in Linux kernel

Quota support has to be enabled in Linux kernel (version 2.6):
CONFIG_QUOTA=y
CONFIG_QUOTACTL=y

Debian packages

Install quota management tools:
apt-get install quota
The package provides utilities for quota initialization, editing and monitoring.

Preparing a filesystem

Any filesystem, for which quotas are imposed, has to be mounted with usrquota and/or grpquota mount options (for user and group quotas respectively). For example, here is /etc/fstab entry on gauss for /home filesystem:
# <file system> <mount point> <type> <options>                  <dump>  <pass>
/dev/hda5       /home         ext3   defaults,usrquota,grpquota 0       2
After modifying /etc/fstab the filesystem has to be remounted with the new options. To minimize the risk of data loss this should be done while in single-user mode (# init 1; back to multi-user mode on Debian: # init 2):
# mount -o remount /home

The root of the filesystem must have quota configuration files. The files will have binary contents and will be edited using edquota utility. Empty files are created for now:

# touch /home/aquota.user
# touch /home/aquota.group

Now quota table has to be initialized (verbose, all filesystems, users, groups, don't remount):

# quotacheck -vaugm

Setting quotas

Quotas are set for individual users or groups:
# edquota <user>
# edquota -g <group>

edquota will invoke the vi (or whatever text editor is in $EDITOR) with the contents similar to this

# edquota sarunas

Disk quotas for user sarunas (uid 1234):
  Filesystem               blocks       soft       hard     inodes     soft     hard
  /dev/hda5                453356          0          0       2769        0        0
Quota can be set by editing soft and hard values (1 kilobyte blocks) and ``saving'', i.e. exit the text editor with the usual Save and Exit. edquota will do the necessary conversion and save to aquota.user file. Users can exceed soft limit temporarily during ``grace'' period, which defaults to 7 days). hard limit can never be exceeded. The same grace period applies to all the users and can be edited by edquota -t.

As of May 2006 soft and hard limits on gauss:/home are 1000000 and 1300000 (roughly 1GB and 1.3GB) respectively.

Living with quotas

Checking manually

To check your own quota(s):
$ quota
Disk quotas for user sarunas (uid 1234):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/hda5  453356  1000000 1300000           2769       0       0

root can check any other user's quota(s):

# quota sarunas
Disk quotas for user sarunas (uid 1234):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/hda5  453356  1000000 1300000           2769       0       0

Report on all users for /home filesystem:

# repquota /home
*** Report for user quotas on device /dev/hda5
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
jjf       --    1556 1000000 1300000             93     0     0
chance    --    9920 1000000 1300000            292     0     0
ftp       -- 1428488 2300000 2500000           4356     0     0
... ... ...

Check quotas and send e-mail notices to users, who are over quota:

# warnquota
Configuration options for e-mail notifications are in /etc/warnquota.conf.

Automated checks

Debian installer configures a daily cron job /etc/cron.daily/quota, which runs warnquota.

Changing quotas

Quotas are added, changed and removed by using edquota <user>. The same quota can be applied to many users by edquota -p joe `cat list-of-users`. The latter will copy joe's quota to users listed in list-of-users file. All quotas can be instantly disabled by:
# quotaoff -v /home
And re-enabled again by:
# quotaon -v /home



Sarunas Burdulis 2006-05-26