Quota

WIP Disk quotas set a limit on the disk space that can be used by a user or group.

See also:
quota(1) - display disk usage and limits
quotactl(2) - manipulate filesystem quotas
edquota(8) - edit user quotas
quotacheck(8) - filesystem quota consistency checker
quotaon, quotaoff(8) - turn filesystem quotas on and off
repquota(8) - summarize quotas for a file system
rpc.rquotad, rquotad(8) - remote quota server
This guide supposes that your quota is set for a user, "billy", in the /home/ partition. However, a quota can be set for any user(s) and/or group(s) on any partition(s).

There are two types of quotas that you can set.

  • Soft quota
Provides you with a warning when you reach it, but you can still use more space until the hard limit is reached, or the grace period elapses (the amount of time to allow a user to get below his quota), which hardens the soft limit. This warning is printed to stderr, after you run a command that uses more disk space.
  • Hard quota
Does not allow the allocation of more disk space. If you have more space used than your hard quota allows (meaning the quota was set after you used the space, or your grace period elapsed), your files are not deleted. You will still be able to read and create files, but you can not write to them. Your editor (vi and ed, at least) will warn you on write:
$filename:  Disk quota exceeded

This means you'll have to lose the content or save it to /tmp/ while you clean up your quota-ed directory.

Inode Quotas

You can also set a quota on the amount of files a user can have. When your reach the soft limit, you get the following error:

/home: warning, user inode quota exceeded

And when the hard limit is reached:

/home: write failed, user inode limit reached
touch: $filename: Disk quota exceeded

NOTE: Exceeding your "files" quota has no effect on the amount of data you can have in your files, and exceeding your "KBytes" quota has no effect on the amount of files you can have.

Enabling quotas: Add the userquota or groupquota flag to the partition you'd like to enable quotas on in /etc/fstab:

7207566f6d99a4f1.a /home ffs rw,nodev,nosuid,userquota 1 2

This enables quotas per-user on the partition mounted to /home.

To give billy a quota of 100MB, hard limit 150MB, quota of 50 files and hard limit of 75 files:

  1. edquota billy
Quotas for user billy:
/home: KBytes in use: 16, limits (soft = 100000, hard = 150000)
        inodes in use: 9, limits (soft = 50, hard = 75)

Save the file, and the quota will come into effect next time he is not logged in. Make sure to check:

# who

You can check billy's diskusage/quota status:

# quota billy

And he can check his own by running:

$ quota

Group quotas are a similar way:

# quota -g billy

or

$ quota -g

NOTE: chown(8) follows disk quotas. If billy is part of group soldier, and has gone over his quota, he cannot create a file under group billy and chown :soldier. Root, however, can do this.

Disk quotas are set to limit amount of disk space per each user, two types of quotas are:

  • Soft quota
Allows allocating more disk space, until either hard limit or grace time reached.
  • Hard quota
Doesn't allow allocating more disk space.

Configuration

Add userquota and/or groupquota into mount options in /etc/fstab. then change them (per user/per group) with edquota.