Limit User's Disk Space (Setting Quotas)
Created: 10/19/2006
General Information
This guide details how to set up user accounts with disk allocation. Let's say you want to limit each user to a specific size disk usage -- 100 megs each. You will need to set "user quotas." Here we go!!Requirements
Configuration
First step is to make sure that quotas are configured into the Kernel. If you are not familiar with the process, learn to compile your kernel.|
options QUOTA |
/etc/rc.conf.| # | echo 'enable_quotas="YES"' >> /etc/rc.conf |
Note: For finer control over your quota startup, there is an additional configuration variable available. Normally on bootup, the quota integrity of each file system is checked by the quotacheck program. The quotacheck facility ensures that the data in the quota database properly reflects the data on the file system. This is a very time consuming process that will significantly affect the time your system takes to boot. If you would like to skip this step, a variable is made available for the purpose:
| # | echo 'check_quotas="NO"' >> /etc/rc.conf |
/etc/rc.conf:| # | echo 'check_quotas="YES"' >> /etc/rc.conf |
/etc/fstab to enable disk quotas on a per-file system basis. This is where you can either enable user or group quotas or both for all of your file systems. To enable per-user quotas on a file system, add the userquota option to the options field in the /etc/fstab entry for the file system you want to to enable quotas on. For example:|
/dev/da1s2g /home ufs rw,userquota 1 2 |
|
/dev/da1s2g /home ufs rw,userquota,groupquota 1 2 |
quota.user and quota.group for user and group quotas respectively. See the fstab man page for more information. Even though that man page says that you can specify an alternate location for the quota files, this is not recommended because the various quota utilities do not seem to handle this properly. At this point you should reboot your system with your new kernel. /etc/rc will automatically run the appropriate commands to create the initial quota files for all of the quotas you enabled in /etc/fstab, so there is no need to manually create any zero length quota files. In the normal course of operations you should not be required to run the quotacheck, quotaon, or quotaoff commands manually. However, you may want to read their man pages just to be familiar with their operation.| # | quota -v |
edquota command. When the edquota command is invoked, you are placed into the editor specified by the EDITOR environment variable, or in the vi editor if the EDITOR variable is not set, to allow you to edit the quota limits.| # | edquota -u test |
|
Quotas for user test: /usr: blocks in use: 65, limits (soft = 50, hard = 75) inodes in use: 7, limits (soft = 50, hard = 60) /usr/var: blocks in use: 0, limits (soft = 50, hard = 75) inodes in use: 0, limits (soft = 50, hard = 60) |
Author: ShadowBumble
ShadowBumble at hotmail dot com