Disk space can be restricted by implementing disk quotas which alert a system administrator before a user consumes too much disk space or a partition becomes full. Disk quotas can be configured for individual users as well as user groups. This makes it possible to manage the space allocated for user-specific files (such as email) separately from the space allocated to the projects a user works on (assuming the projects are given their own groups).
In addition, quotas can be set not just to control the number of disk blocks consumed but to control the number of inodes (data structures that contain information about files in UNIX file systems). Because inodes are used to contain file-related information, this allows control over the number of files that can be created.
* Features of quotas
1). Limits disk usage (blocks or inodes)
2). Tied to file systems (et 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
a) defaults,usrquota,grpquota
Example:
#vi /etc/fstab
/dev/Volgroup00/logVol02/home ext3 defaults,usrquota,grpquota 1 2
2) Remount the file system(s)
a) mount -o remount /
b) use 'mount' to confirm that 'usrquota, grpquota' support are enabled
Example:
#mount -o remount /home
3) Create quota database files and generate disk usage table
a) quotacheck -mcug / (where c-create, u-user, g- group)
This creates /aquota.user and aquota.group
b) quotacheck -mavu
4) Assign quota policies:
a) edquota username (set blocks/inodes, soft_limits, hard_limits)
Example:
edquota student1 (sets quotas for user student1)
b) edquota -g devl
(for group quota, check using #quota -g devl)
5) Check quotas
#quota username
Example:
#quota student1
6) Report on usage
#repquota -a
==> The blocks are measured in 1K increments, eg 20000 blocks is roughly 20 MB.
* To change the grace period of quota
#edquota -t
* Managing quotas
If quotas are implemented, they need some maintenance-mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate.
a) Enabling and disabling quotas
i) To turn all user and group quotas off
#quotaoff -vuag
If neither the -u and -g options are specified, only the user quotas are disabled. If only -g is specified, only group quotas are disabled. The -v switches causes verbose status informtion to display as the command executes.
ii) To enable quotas again:
#quotaon -vaug
To enable quotas for a specific file system, such as /home, use the following
#quotaon -vug /home
If neither the -u or -g options are specified, only the user quotas are enabled. If only -g is specified, only group quotas are enabled.
b) Reporting on Disk Quotas
#repquota -a
c) Keeping Quotas accurate
Whenever a file system is not unmounted clearly (due to a system crash, for eg), it is necessary to run quotacheck. Running the following command periodically keeps the quotas more accurate.
#quotacheck -avug
The easiest way to run it periodically is to use cron.
In addition, quotas can be set not just to control the number of disk blocks consumed but to control the number of inodes (data structures that contain information about files in UNIX file systems). Because inodes are used to contain file-related information, this allows control over the number of files that can be created.
* Features of quotas
1). Limits disk usage (blocks or inodes)
2). Tied to file systems (et 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
a) defaults,usrquota,grpquota
Example:
#vi /etc/fstab
/dev/Volgroup00/logVol02/home ext3 defaults,usrquota,grpquota 1 2
2) Remount the file system(s)
a) mount -o remount /
b) use 'mount' to confirm that 'usrquota, grpquota' support are enabled
Example:
#mount -o remount /home
3) Create quota database files and generate disk usage table
a) quotacheck -mcug / (where c-create, u-user, g- group)
This creates /aquota.user and aquota.group
b) quotacheck -mavu
4) Assign quota policies:
a) edquota username (set blocks/inodes, soft_limits, hard_limits)
Example:
edquota student1 (sets quotas for user student1)
b) edquota -g devl
(for group quota, check using #quota -g devl)
5) Check quotas
#quota username
Example:
#quota student1
6) Report on usage
#repquota -a
==> The blocks are measured in 1K increments, eg 20000 blocks is roughly 20 MB.
* To change the grace period of quota
#edquota -t
* Managing quotas
If quotas are implemented, they need some maintenance-mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate.
a) Enabling and disabling quotas
i) To turn all user and group quotas off
#quotaoff -vuag
If neither the -u and -g options are specified, only the user quotas are disabled. If only -g is specified, only group quotas are disabled. The -v switches causes verbose status informtion to display as the command executes.
ii) To enable quotas again:
#quotaon -vaug
To enable quotas for a specific file system, such as /home, use the following
#quotaon -vug /home
If neither the -u or -g options are specified, only the user quotas are enabled. If only -g is specified, only group quotas are enabled.
b) Reporting on Disk Quotas
#repquota -a
c) Keeping Quotas accurate
Whenever a file system is not unmounted clearly (due to a system crash, for eg), it is necessary to run quotacheck. Running the following command periodically keeps the quotas more accurate.
#quotacheck -avug
The easiest way to run it periodically is to use cron.