IRCNow

This is an old revision of the document!


Disk quotas

Disk quotas are used to place limits on the amount of disk space available to certain users and groups. There are two types of quotas - soft and hard quotas.

  1. soft quotas - once threshold is reached, warns the users and sets a grace period time so they can decrease their disk usage below limits. After the grace period is over, the soft limit is handled as a hard limit
  2. hard quotas - does not allow any more disk allocation once threshold is reached.

Currently, IRCNow's shell limits disk usage to 5GB (soft) and 10GB (hard) per user.

Setting up

To enable quotas, We need to mark all the desired filesystems by adding the keywords userquota and/or groupquota in fstab(5) on which filesystem We want to be able to enforce quotas. By default, files quota.user and quota.group will be created at the root of those filesystems.

/dev/sda.a /home ffs rw,nodev,nosuid,userquota 1 2

Defining limits

To set thresholds, We use edquota(8). Keep in mind that values are measured in KB (1MB equals to 1000KB).

$ edquota [-u] PiRATA
Quotas for user PiRATA:
/home: KBytes in use: 62, limits (soft = 256000, hard = 512000)
        inodes in use: 25, limits (soft = 0, hard = 0)
 
$ edquota -g staff
Quotas for group staff:
/home: KBytes in use: 62, limits (soft = 1000000, hard = 1500000)
        inodes in use: 25, limits (soft = 0, hard = 0)       

On the first above, PiRATA can use up to 512MB on his $HOME. On the latter. all staff users are limited to 15GB of disk space.

Now, what if you need to define a certain threshold for 7 or 8 users or even 50? What would you do? Probably you would use edquota(8) for each user. Gladly, We don't need to - by invoking -p option followed by the user that all the other users will replicate from and then specify all users.

$ edquota -p PiRATA jrmu jimmy_will dennis  

By invoking the -t option, grate time can be configured:

$ edquota -t search_social
Time units may be: days, hours, minutes, or seconds
Grace period before enforcing soft limits for users:

/home: block grace period: 7 days, file grace period: 7 days

Enabling/Disabling quotas

To turn on or off disk quotas, use quotaon(8) and/or quotaoff(8).

// Enables disk quotas on all filyesystems that have the user/diskquota flag defined on fstab(5)
$ quotaon -a
 
// Disables disk quotas for user net_wayfarer
$ quotaoff -u net_wayfarer

Displaying limits

quota(1) outputs current disk usage and limits. By default, only the user quotas are printed but you can see group quotas by invoking -g option.

$ quota jrmu
Disk quotas for user jrmu (uid 1012): 
  Filesystem  KBytes    quota   limit   grace    files   quota   limit   grace
       /home    3704  5000000 10000000              58        0       0