12/12/96, 4FAX# 2929 Setup and Use of the Disk Quota System SPECIAL NOTICES Information in this document is correct to the best of our knowledge at the time of this writing. Please send feedback by fax to "AIXServ Information" at (512) 823-4009. Please use this information with care. IBM will not be responsible for damages of any kind resulting from its use. The use of this information is the sole responsibility of the customer and depends on the customer's ability to eval- uate and integrate this information into the customer's operational environment. +----------------------------------------------------------+ | | | NOTE: The information in this document has NOT been | | verified for AIX 4.1. | | | +----------------------------------------------------------+ ABOUT THE DISK QUOTA SYSTEM A Disk Quota System, providing a method for controlling disk space usage, has been implemented in AIX 3.2. This system is based on the Berkeley Disk Quota System and allows assignment of quotas for the AIX journaled file system only. Disk quotas may be assigned based on three parameters and can be modified with the edquota command. The three parame- ters are: o A user's or group's soft limits -- the number of 1 KB disk blocks or files below which the user should remain. o A user's or group's hard limits -- the maximum number of disk blocks or files the user can accumulate. o Quota grace period -- there is a grace period during which the soft limit can be exceeded (the default is one week). If the user fails to reduce usage below the soft limit during the specified time, the system will inter- pret the soft limit as the maximum allocation for that user. No further storage will be allocated to the user. The user may correct this condition by removing enough files to reduce usage to below the soft limit. The disk quota system tracks user and group quotas in the "quota.user" and "quota.group" files. These files reside in the root directories of file systems that have quotas assigned. These files are created with the "edquota" and "quotacheck" commands and are readable with the quota com- mands. Setup and Use of the Disk Quota System 1 12/12/96, 4FAX# 2929 WHEN TO USE THE QUOTA SYSTEM Typically, quotas are only used for file systems that contain user home directories and files. It is recommended that disk quotas never be assigned for the /tmp file system. A system administrator would consider implementing the disk quota system under the following conditions: o The system has limited disk space o More file system security is desired o Disk usage levels by users are large SETUP OF THE DISK QUOTA SYSTEM In order to set up the disk quota system, you must have root-user level authority. 1. Determine the file system(s) to which you will apply quotas. (In AIX 3.2, user directories default to the /home file system.) 2. The stanza that applies to the /home file system (or to another file system to which you are applying quotas) should be identified and edited in the /etc/filesystems file so that it includes quota, userquota, and groupquota configuration attributes. Here is an example stanza line which enables user quotas: quota = userquota In a file system that has both user and group quotas enabled, the entry might look similar to the following: /home: dev = /dev/hd1 vol = "/home" mount = true check = true free = false vfs = jfs log = /dev/hd8 quota = userquota,groupquota options = rw 3. You have the option of specifying disk quota file names. The default files are "quota.user" and "quota.group", located in the root directory of the file system enabled with quotas. You may specify alternate names or direc- tories for these quota files with the "userquota" and "groupquota" attributes. Here is a sample entry for user "bill" of the "dquota" group: Setup and Use of the Disk Quota System 2 12/12/96, 4FAX# 2929 /home: dev = /dev/hd1 vol = "/home" mount = true check = true free = false vfs = jfs log = /dev/hd8 quota = userquota,groupquota userquota = /home/myquota.bill groupquota = /home/myquota.qgroup options = rw 4. If the file systems are not mounted, mount them. 5. Use the edquota command to set the user or group soft and hard limits. The edquota command has the following syntax: User Quotas edquota -u ( -p Proto-UserName ) UserName .. Group Quotas edquota -g ( -p Proto-GroupName ) GroupName ... The edquota command creates and edits quotas. It creates a temporary file that contains each user's and group's current disk quotas. It determines the list of file systems with established quotas from the /etc/filesystems file. The edquota command invokes the vi editor (or the editor specified by the EDITOR environment variable) on the temporary file, so that quotas can be added and modi- fied. The fields that are displayed in the temporary file are: o Blocks in use: The current number of 1K-byte file system blocks used by this user or group. o Inodes in use: The current number of files used by this user or group. o Block soft limit: The number of 1K-byte blocks the user or group will be allowed to use during normal operations. o Block hard limit: The total amount of 1K-byte blocks the user or group will be allowed to use, including temporary storage during a quota grace period. o Inode soft limit: The number of files the user or group will be allowed to create during normal oper- ations. Setup and Use of the Disk Quota System 3 12/12/96, 4FAX# 2929 o Inode hard limit: The total number of files the user or group will be allowed to create, including temporary files created during a quota grace period. NOTE: A hard limit with a value of "1" indicates that no allocations are permitted. A soft limit with a value of 1, in conjunction with a hard limit with a value of 0, indicates that allocations are permitted only on a temporary basis. More information on the edquota command can be found in InfoExplorer and the "edquota" man page or in the hard- copy manuals. Here is a sample edquota command and editing session: #edquota -u bill Quotas for user bill: /home: blocks in use: 16, limits (soft = 10, hard = 30) inodes in use: 4, limits (soft = 0, hard = 0) Change User or Group Grace Period edquota -t -u | -g -t Changes the grace period during which quotas can be exceeded before a soft limit is imposed as a hard limit. The default value of the grace period is 1 week. When invoked with the -u flag, the grace period is set for all file systems with user quotas specified in the /etc/filesystems file. When invoked with the -g flag, the grace period is set for all file systems with group quotas specified in the /etc/filesystems file. NOTE: If the grace period is changed and repquota shows that some users are already reached their old grace period - before the new grace period can take effect for these users - these users must reduce their quotas to below their soft limits to reset the old grace period - now in the future if these users exceed their soft limits - the new grace period will be in effect. Also - if another user (like root) - exceeds another users quota, the grace period as reported by the repquota command will show ( none ). The overlimit must be corrected by the user and then when the the quota limit is exceeded the next time - the grace period will be seen with the correct value. 6. The quota system must be enabled with the quotaon command. The syntax for the quotaon - quotaoff commands are: Setup and Use of the Disk Quota System 4 12/12/96, 4FAX# 2929 Purpose - Turns file system quotas on and off. quotaon [ -g -u -v ] { -a | FileSystem ... } quotaoff [ -g -u -v ] { -a | FileSystem ... } The quotaon command enables disk quotas for one or more file systems specified by the FileSystem parameter. The specified file system must have an entry in the /etc/filesystems file and must be mounted. The "quotaon" command looks for the "quota.user" and "quota.group" default files in the root directory of the associated file system. These file names may be changed in the /etc/filesystems file. By default, both user and group quotas are enabled. The related flags or options are: -a Enables or disables all file systems that are read-write and have disk quotas, as indicated by the /etc/filesystems file. When used with the -g flag, enables or disables only group quotas in the /etc/filesystems file; when used with the -u flag, enables or disables only user quotas in the /etc/filesystems file. -g Specifies that only group quotas are enabled or disabled. -u Specifies that only user quotas are enabled or disabled. -v Prints a message for each file system in which quotas are turned on or off. Examples: o To enable user quotas for the /home file system, enter: quotaon -u /home o To disable user and group quotas for all file systems in the /etc/filesystems file and print a message, enter: quotaoff -v -a 7. Use the quotacheck command to check the quota files against actual disk usage. It is recommended that you do this each time you first enable quotas on a file system and after you reboot the system. WARNING: It is recommended that the specified file system not be active while the quotacheck command is running. Executing quotacheck on an active file system (i.e., users have open files) can result in corrupt or incorrect quota data. Run quotacheck only from single- user mode or from the /etc/rc file during boot up (as shown below). Setup and Use of the Disk Quota System 5 12/12/96, 4FAX# 2929 The quotacheck process can be automated during boot up with the following entries added near the end of the /etc/rc file (after execution of the fsck command but before the "multi-user initialization completed" message): echo " Enabling file system quotas" /usr/sbin/quotacheck [-g -u -v] { -a | filesystem...} /usr/sbin/quotaon [-g -u -v] { -a | filesystem...} The quotacheck command checks for file system consist- ency and has the following format and syntax: quotacheck [-g -u -v] { -a | Filesystem ...} By default, both user and group quotas are checked. The flags are -a Checks all file systems with disk quotas and read-write permissions indicated by the /etc/filesystems file. -g Checks group quotas only. -u Checks user quotas only. -v Reports discrepancies between the calculated and recorded disk quotas. Examples: o To check the user and group quotas in the /home file system, enter: quotacheck /home o To check only the group quotas in the /home file system, enter: quotacheck -g /home 8. You can use the repquota command to print a summary of quotas and disk usage for a file system. If the -a flag is specified instead of a file system, the repquota command prints the summary for all file systems enabled with quotas. By default, repquota [-v -g -u] { -a | FileSystem ...} -a Specifies that quotas are printed for all file systems enabled. -g Specifies that only group quotas are printed. -u Specifies that only user quotas are printed. -v Prints a header line before the summary of quotas for each file system. Example: Setup and Use of the Disk Quota System 6 12/12/96, 4FAX# 2929 To print a summary of user quotas in the /home file system, enter: repquota -u /home The system prints the following information: Block limits File limit User used soft hard grace used soft hard grace root -- 16 0 0 2 0 0 lanczi -- 12 3000 5000 3 3600 4500 biff -- 8 20 40 2 30 39 bill -- 16 10 30 7days 4 11 30 DISK QUOTA FIXES For AIX 3.2.5 Fixes (PTFs) for AIX 3.2.5 and later can be downloaded via Internet with the FixDist service. For FixDist information and instructions, order fax number 1228 from 1-800-IBM-4FAX. If you don't have access to Internet or if your machine is at a pre-3.2.5 AIX level, you can request a specific fix number from 1-800-CALL-AIX. All other services from 1-800-CALL-AIX which are not Program Services require a software support contract. APAR # PROBLEM FIXED IX40342 File system quotas may be incorrect. Each new file block is counted twice, causing users to exceed the quota. IX42766 quotacheck truncates quotas file. IX42886 quota allows blocks and inodes to become "nega- tive". IX44418 quotacheck does not account for all files in a filesystem. When all files are finally removed, the user would have a large block, file count. This was caused by a change in APAR IX42887 which has been superseded by IX44418. REFERENCES For more information, see the "Disk Quota System Overview" and the "edquota" command in InfoExplorer. Setup and Use of the Disk Quota System 7 12/12/96, 4FAX# 2929 READER'S COMMENTS Please fax this form to (512) 823-4009, attention "AIXServ Informa- tion". You may also e-mail comments to: elizabet@austin.ibm.com. These comments should include the same customer information requested below. Use this form to tell us what you think about this document. If you have found errors in it, or if you want to express your opinion about it (such as organization, subject matter, appearance) or make sug- gestions for improvement, this is the form to use. If you need technical assistance, contact your local branch office, point of sale, or 1-800-CALL-AIX (for information about support offer- ings). These services may be billable. Faxes on a variety of sub- jects may be ordered free of charge from 1-800-IBM-4FAX. Outside the U.S. call 415-855-4329 using a fax machine phone. When you send comments to IBM, you grant IBM a nonexclusive right to use or distribute your comments in any way it believes appropriate without incurring any obligation to you. NOTE: If you have a problem report or item number, supplying that number may help us determine why a procedure did or did not work in your specific situation. Problem Report or Item #: Branch Office or Customer #: Be sure to print your name and fax number below if you would like a reply: Name: Fax Number: ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ ______________________________________________________________________ END OF DOCUMENT (disk.quota.setup.cmd, 4FAX# 2929) Setup and Use of the Disk Quota System 8