Disk quota management
December 8th, 2008 at 8:23pm |
You may need to set a maximum disk quota per user, so that one user cannot fill up the whole system with his documents/garbage.
A disk quota is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems.
There are two basic types of disk quotas. The first, known as a usage quota or block quota, limits the amount of disk space that can be used. The second, known as a file quota or inode quota, limits the number of files and directories that can be created.
- install package quota
sudo apt-get install quota - add option usrquota to the /etc/fstab partition you want to restrict
- remount that partition to make the changes effective
sudo mount -o remount /dev/[device]
Note: ensure nobody is working on that parition, if in doubt run init 1 to switch to runlevel 1 - create quota config files in the topmost directory of the filesystem
sudo touch aquota.user
sudo touch aquota.group - make linux read the quota config file
quotacheck -vagum - edit users’s quota information
- edquota -u user
this invokes VI editor, thus you may have to refer to this post on how to use VI
BLOCKS is the amount of space (in 1k blocks) the user is currently using
INODES is the number of files the user currently owns
SOFT LIMIT is the maximum blocks/inodes a quota user may have on the partition when the grace period is set. If set to 0 limits are disabled.
HARD LIMIT is the maximim blocks/inodes a quota user may have on a partition. If set to 0 limits are disabled. - enforce the quotas. Linux does not constantly monitor the disk quota usage. To make it check it periodically set a CRON JOB to run a script like this
#! /bin/bash
quotackeck -vaguon a few minutes/hours basis
- grace periods. When a user exceeds the soft quota limit its is warned by the system, however he is still able to create new files, until he reaches the HARD LIMIT quota, for a limited amount of time (which is the grace period).
this can be set this way
edquota -t - edit grout quota
edquota -g - getting quota reports
repquota /dev/[device]