|
|
1.1 ! root 1: .\" Copyright (c) 1983 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)quotas.ms 6.2 (Berkeley) 7/31/86 ! 6: .\" ! 7: .EH 'SMM:4-%''Disc Quotas in a \s-2UNIX\s+2 Environment' ! 8: .OH 'Disc Quotas in a \s-2UNIX\s+2 Environment''SMM:4-%' ! 9: .ND 5th July, 1983 ! 10: .TL ! 11: Disc Quotas in a \s-2UNIX\s+2\s-3\u*\d\s0 Environment ! 12: .FS ! 13: * UNIX is a trademark of Bell Laboratories. ! 14: .FE ! 15: .AU ! 16: Robert Elz ! 17: .AI ! 18: Department of Computer Science ! 19: University of Melbourne, ! 20: Parkville, ! 21: Victoria, ! 22: Australia. ! 23: .AB ! 24: .PP ! 25: In most computing environments, disc space is not ! 26: infinite. ! 27: The disc quota system provides a mechanism ! 28: to control usage of disc space, on an ! 29: individual basis. ! 30: .PP ! 31: Quotas may be set for each individual user, on any, or ! 32: all filesystems. ! 33: .PP ! 34: The quota system will warn users when they ! 35: exceed their allotted limit, but allow some ! 36: extra space for current work. ! 37: Repeatedly remaining over quota at logout, ! 38: will cause a fatal over quota condition eventually. ! 39: .PP ! 40: The quota system is an optional part of ! 41: \s-2VMUNIX\s0 that may be included when the ! 42: system is configured. ! 43: .AE ! 44: .NH 1 ! 45: Users' view of disc quotas ! 46: .PP ! 47: To most users, disc quotas will either be of no concern, ! 48: or a fact of life that cannot be avoided. ! 49: The ! 50: \fIquota\fP\|(1) ! 51: command will provide information on any disc quotas ! 52: that may have been imposed upon a user. ! 53: .PP ! 54: There are two individual possible quotas that may be ! 55: imposed, usually if one is, both will be. ! 56: A limit can be set on the amount of space a user ! 57: can occupy, and there may be a limit on the number ! 58: of files (inodes) he can own. ! 59: .PP ! 60: .I Quota ! 61: provides information on the quotas that have ! 62: been set by the system administrators, in each ! 63: of these areas, and current usage. ! 64: .PP ! 65: There are four numbers for each limit, the current ! 66: usage, soft limit (quota), hard limit, and number ! 67: of remaining login warnings. ! 68: The soft limit is the number of 1K blocks (or files) ! 69: that the user is expected to remain below. ! 70: Each time the user's usage goes past this limit, ! 71: he will be warned. ! 72: The hard limit cannot be exceeded. ! 73: If a user's usage reaches this number, further ! 74: requests for space (or attempts to create a file) ! 75: will fail with an EDQUOT error, and the first time ! 76: this occurs, a message will be written to the user's ! 77: terminal. ! 78: Only one message will be output, until space occupied ! 79: is reduced below the limit, and reaches it again, ! 80: in order to avoid continual noise from those ! 81: programs that ignore write errors. ! 82: .PP ! 83: Whenever a user logs in with a usage greater than ! 84: his soft limit, he will be warned, and his login ! 85: warning count decremented. ! 86: When he logs in under quota, the counter is reset ! 87: to its maximum value (which is a system configuration ! 88: parameter, that is typically 3). ! 89: If the warning count should ever reach zero (caused ! 90: by three successive logins over quota), the ! 91: particular limit that has been exceeded will be treated ! 92: as if the hard limit has been reached, and no ! 93: more resources will be allocated to the user. ! 94: The \fBonly\fP way to reset this condition is ! 95: to reduce usage below quota, then log in again. ! 96: .NH 2 ! 97: Surviving when quota limit is reached ! 98: .PP ! 99: In most cases, the only way to recover from over ! 100: quota conditions, is to abort whatever activity was in progress ! 101: on the filesystem that has reached its limit, remove ! 102: sufficient files to bring the limit back below quota, ! 103: and retry the failed program. ! 104: .PP ! 105: However, if you are in the editor and a write fails ! 106: because of an over quota situation, that is not ! 107: a suitable course of action, as it is most likely ! 108: that initially attempting to write the file ! 109: will have truncated its previous contents, so should ! 110: the editor be aborted without correctly writing the ! 111: file not only will the recent changes be lost, but ! 112: possibly much, or even all, of the data ! 113: that previously existed. ! 114: .PP ! 115: There are several possible safe exits for a user ! 116: caught in this situation. ! 117: He may use the editor \fB!\fP shell escape command to ! 118: examine his file space, and remove surplus files. ! 119: Alternatively, using \fIcsh\fP, he may suspend the ! 120: editor, remove some files, then resume it. ! 121: A third possibility, is to write the file to ! 122: some other filesystem (perhaps to a file on /tmp) ! 123: where the user's quota has not been exceeded. ! 124: Then after rectifying the quota situation, ! 125: the file can be moved back to the filesystem ! 126: it belongs on. ! 127: .NH 1 ! 128: Administering the quota system ! 129: .PP ! 130: To set up and establish the disc quota system, ! 131: there are several steps necessary to be performed ! 132: by the system administrator. ! 133: .PP ! 134: First, the system must be configured to include ! 135: the disc quota sub-system. ! 136: This is done by including the line: ! 137: .DS ! 138: options QUOTA ! 139: .DE ! 140: in the system configuration file, then running ! 141: \fIconfig\fP\|(8) ! 142: followed by a system configuration\s-3\u*\d\s0. ! 143: .FS ! 144: * See also the document ``Building 4.2BSD UNIX Systems with Config''. ! 145: .FE ! 146: .PP ! 147: Second, a decision as to what filesystems need to have ! 148: quotas applied needs to be made. ! 149: Usually, only filesystems that house users' home directories, ! 150: or other user files, will need to be subjected to ! 151: the quota system, though it may also prove useful to ! 152: also include \fB/usr\fR. ! 153: If possible, \fB/tmp\fP should usually be free of quotas. ! 154: .PP ! 155: Having decided on which filesystems quotas need to be ! 156: set upon, the administrator should then allocate the ! 157: available space amongst the competing needs. How this ! 158: should be done is (way) beyond the scope of this document. ! 159: .PP ! 160: Then, the ! 161: \fIedquota\fP\|(8) ! 162: command can be used to actually set the limits desired upon ! 163: each user. Where a number of users are to be given the ! 164: same quotas (a common occurrence) the \fB\-p\fP switch ! 165: to edquota will allow this to be easily accomplished. ! 166: .PP ! 167: Once the quotas are set, ready to operate, the system ! 168: must be informed to enforce quotas on the desired filesystems. ! 169: This is accomplished with the ! 170: \fIquotaon\fP\|(8) ! 171: command. ! 172: .I Quotaon ! 173: will either enable quotas for a particular filesystem, or ! 174: with the \fB\-a\fP switch, will enable quotas for each ! 175: filesystem indicated in \fB/etc/fstab\fP as using quotas. ! 176: See ! 177: \fIfstab\fP\|(5) ! 178: for details. ! 179: Most sites using the quota system, will include the ! 180: line ! 181: .DS C ! 182: /etc/quotaon -a ! 183: .DE ! 184: in \fB/etc/rc.local\fP. ! 185: .PP ! 186: Should quotas need to be disabled, the ! 187: \fIquotaoff\fP(8) ! 188: command will do that, however, should the filesystem be ! 189: about to be dismounted, the ! 190: \fIumount\fP\|(8) ! 191: command will disable quotas immediately before the ! 192: filesystem is unmounted. ! 193: This is actually an effect of the ! 194: \fIumount\fP\|(2) ! 195: system call, and it guarantees that the quota system ! 196: will not be disabled if the umount would fail ! 197: because the filesystem is not idle. ! 198: .PP ! 199: Periodically (certainly after each reboot, and when quotas ! 200: are first enabled for a filesystem), the records retained ! 201: in the quota file should be checked for consistency with ! 202: the actual number of blocks and files allocated to ! 203: the user. ! 204: The ! 205: \fIquotacheck\fP\|(8) ! 206: command can be used to accomplish this. ! 207: It is not necessary to dismount the filesystem, or disable ! 208: the quota system to run this command, though on ! 209: active filesystems inaccurate results may occur. ! 210: This does no real harm in most cases, another run of ! 211: .I quotacheck ! 212: when the filesystem is idle will certainly correct any inaccuracy. ! 213: .PP ! 214: The super-user may use the ! 215: \fIquota\fP\|(1) ! 216: command to examine the usage and quotas of any user, and ! 217: the ! 218: \fIrepquota\fP\|(8) ! 219: command may be used to check the usages and limits for ! 220: all users on a filesystem. ! 221: .NH 1 ! 222: Some implementation detail. ! 223: .PP ! 224: Disc quota usage and information is stored in a file on the ! 225: filesystem that the quotas are to be applied to. ! 226: Conventionally, this file is \fBquotas\fR in the root of ! 227: the filesystem. ! 228: While this name is not known to the system in any way, ! 229: several of the user level utilities "know" it, and ! 230: choosing any other name would not be wise. ! 231: .PP ! 232: The data in the file comprises an array of structures, indexed ! 233: by uid, one structure for each user on the system (whether ! 234: the user has a quota on this filesystem or not). ! 235: If the uid space is sparse, then the file may have holes ! 236: in it, which would be lost by copying, so it is best to ! 237: avoid this. ! 238: .PP ! 239: The system is informed of the existence of the quota ! 240: file by the ! 241: \fIsetquota\fP\|(2) ! 242: system call. ! 243: It then reads the quota entries for each user currently ! 244: active, then for any files open owned by users who ! 245: are not currently active. ! 246: Each subsequent open of a file on the filesystem, will ! 247: be accompanied by a pairing with its quota information. ! 248: In most cases this information will be retained in core, ! 249: either because the user who owns the file is running some ! 250: process, because other files are open owned by the same ! 251: user, or because some file (perhaps this one) was recently ! 252: accessed. ! 253: In memory, the quota information is kept hashed by user-id ! 254: and filesystem, and retained in an LRU chain so recently ! 255: released data can be easily reclaimed. ! 256: Information about those users whose last process has ! 257: recently terminated is also retained in this way. ! 258: .PP ! 259: Each time a block is accessed or released, and each time an inode ! 260: is allocated or freed, the quota system gets told ! 261: about it, and in the case of allocations, gets the ! 262: opportunity to object. ! 263: .PP ! 264: Measurements have shown ! 265: that the quota code uses a very small percentage of the system ! 266: cpu time consumed in writing a new block to disc. ! 267: .NH 1 ! 268: Acknowledgments ! 269: .PP ! 270: The current disc quota system is loosely based upon a very ! 271: early scheme implemented at the University of New South ! 272: Wales, and Sydney University in the mid 70's. That system ! 273: implemented a single combined limit for both files and blocks ! 274: on all filesystems. ! 275: .PP ! 276: A later system was implemented at the University of Melbourne ! 277: by the author, but was not kept highly accurately, eg: ! 278: chown's (etc) did not affect quotas, nor did i/o to a file ! 279: other than one owned by the instigator. ! 280: .PP ! 281: The current system has been running (with only minor modifications) ! 282: since January 82 at Melbourne. ! 283: It is actually just a small part of a much broader resource ! 284: control scheme, which is capable of controlling almost ! 285: anything that is usually uncontrolled in unix. The rest ! 286: of this is, as yet, still in a state where it is far too ! 287: subject to change to be considered for distribution. ! 288: .PP ! 289: For the 4.2BSD release, much work has been done to clean ! 290: up and sanely incorporate the quota code by Sam Leffler and ! 291: Kirk McKusick at The University of California at Berkeley.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.