Disk Quotas
Disk Quotas can be used for several Administrative tasks. The main goal on implementing quotas is to prevent a user, application or log file from overwhelming the system or taking up more space than whet they are allowed to use. Disk quotas are implemented on a per-file system basis and can be set at the user level or the group level.
There are three concepts to keep in mind when dealing with quotas; they are Hard Limits, Soft Limits, and Grace Periods. A Hard Limit is the maximum amount of used space that can be used. Once this limit has been reached, nothing else can be saved to this disk space. A Soft Limit is similar to a Hard Limit except that the user can still save files to the disk. Usually Administrators will set a soft limit to give the user warnings about reaching a limit on their use and then use a hard limit to put a maximum amount of space that the user or group can use. The final concept is Grace Period. A Grace Period is the time during which a soft Limit can be exceeded. This value can be expressed in seconds, minutes, hours, days, weeks, or months.
There are four main steps to follow when implementing quotas. They are edit /etc/fstab, remount the file systems, run quotacheck, assign quotas.
The first step is to open /etc/fstab in a text editor. There are six fields in the /etc/fstab and the field we are interested in is the fourth field which describes the different mount options. This field is formatted as a comma separated list of options. For our use today we are interested in adding the options usrquota or grpquota.
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
LABEL=/home/home ext3 defaults,usrquota,grpquota 1 2
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
If you want quotas to be implemented on only a certain area such as the home directory there has to be a listing for the home directory within /etc/fstab. I’ve shown in the listing above how the /etc/fstab should look after it has been modified. The next step is the save the changes and exit the text editor. Also, the directory you are going to add quotas onto should already be identified as a block device within the system. If it isn't then open up disk druid and repartition your hard drive to set up the /home directory as a separate partition.
The second step in setting up quotas is to remount the file systems which were changed when you edited /etc/fstab. You can either remount the file systems which were changed or reboot the system.
The third step is to run the quotacheck command. When quotacheck is ran it will examine each file system, build a table of current disk usage, and compare this table against that recorded in the disk quota file for the file system. By default user and group quotas are checked. Quotacheck checks the system for two files called .quota.user and/or .quota.group located at root’s filesystem. If quotacheck doesn’t find the files it will create them automatically.
The quotacheck command to be used is quotacheck –uagv. The option – u checks for user disk quota information, -a checks for all quota-enabled, locally-mounted file systems, -g checks for group disk quota information, and –v displays the information verbosely.
Once quotacheck has finished it will display the results in a table which will detail the quotas enabled for each user and group. Now we can start assigning quotas.
The final step is to assign quotas. The edquota program edits both user and group quotas. The edquota program uses a text editor to make changes. Any setting which is left at 0 implies there is no limit for that value or no quota for that setting. The command to use is edquota –u
Disk quotas for user Frank (uid 502):
Filesystem blocks soft hard inodes soft hard
/dev/hda3 24 0 0 7 0 0
Blocks are the amount of space in 1K blocks the user is currently using and inodes are the number of files the user is currently using. The soft and hard limits were explained earlier. Save and exit the file and your quotas are installed.
To monitor quotas you can use the repquota command which reports quota information for specified file systems, users or groups. Once again there are four options a user can use and they are the same ones as used for the quotacheck command.
Running the command quotacheck on a regular basis is a good administrative tool to ensure the tables are kept current. Adding the command quotacheck –uagv to a weekly cron file is the best option here.
There are three concepts to keep in mind when dealing with quotas; they are Hard Limits, Soft Limits, and Grace Periods. A Hard Limit is the maximum amount of used space that can be used. Once this limit has been reached, nothing else can be saved to this disk space. A Soft Limit is similar to a Hard Limit except that the user can still save files to the disk. Usually Administrators will set a soft limit to give the user warnings about reaching a limit on their use and then use a hard limit to put a maximum amount of space that the user or group can use. The final concept is Grace Period. A Grace Period is the time during which a soft Limit can be exceeded. This value can be expressed in seconds, minutes, hours, days, weeks, or months.
There are four main steps to follow when implementing quotas. They are edit /etc/fstab, remount the file systems, run quotacheck, assign quotas.
The first step is to open /etc/fstab in a text editor. There are six fields in the /etc/fstab and the field we are interested in is the fourth field which describes the different mount options. This field is formatted as a comma separated list of options. For our use today we are interested in adding the options usrquota or grpquota.
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
LABEL=/home/home ext3 defaults,usrquota,grpquota 1 2
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
If you want quotas to be implemented on only a certain area such as the home directory there has to be a listing for the home directory within /etc/fstab. I’ve shown in the listing above how the /etc/fstab should look after it has been modified. The next step is the save the changes and exit the text editor. Also, the directory you are going to add quotas onto should already be identified as a block device within the system. If it isn't then open up disk druid and repartition your hard drive to set up the /home directory as a separate partition.
The second step in setting up quotas is to remount the file systems which were changed when you edited /etc/fstab. You can either remount the file systems which were changed or reboot the system.
The third step is to run the quotacheck command. When quotacheck is ran it will examine each file system, build a table of current disk usage, and compare this table against that recorded in the disk quota file for the file system. By default user and group quotas are checked. Quotacheck checks the system for two files called .quota.user and/or .quota.group located at root’s filesystem. If quotacheck doesn’t find the files it will create them automatically.
The quotacheck command to be used is quotacheck –uagv. The option – u checks for user disk quota information, -a checks for all quota-enabled, locally-mounted file systems, -g checks for group disk quota information, and –v displays the information verbosely.
Once quotacheck has finished it will display the results in a table which will detail the quotas enabled for each user and group. Now we can start assigning quotas.
The final step is to assign quotas. The edquota program edits both user and group quotas. The edquota program uses a text editor to make changes. Any setting which is left at 0 implies there is no limit for that value or no quota for that setting. The command to use is edquota –u
Disk quotas for user Frank (uid 502):
Filesystem blocks soft hard inodes soft hard
/dev/hda3 24 0 0 7 0 0
Blocks are the amount of space in 1K blocks the user is currently using and inodes are the number of files the user is currently using. The soft and hard limits were explained earlier. Save and exit the file and your quotas are installed.
To monitor quotas you can use the repquota command which reports quota information for specified file systems, users or groups. Once again there are four options a user can use and they are the same ones as used for the quotacheck command.
Running the command quotacheck on a regular basis is a good administrative tool to ensure the tables are kept current. Adding the command quotacheck –uagv to a weekly cron file is the best option here.
