📄 quotas.ms
字号:
.\" Copyright (c) 1983, 1993.\" The Regents of the University of California. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)quotas.ms 8.1 (Berkeley) 6/8/93.\".EH 'SMM:4-%''Disc Quotas in a \s-2UNIX\s+2 Environment'.OH 'Disc Quotas in a \s-2UNIX\s+2 Environment''SMM:4-%'.ND 5th July, 1983.TLDisc Quotas in a \s-2UNIX\s+2\s-3\u*\d\s0 Environment.FS* UNIX is a trademark of Bell Laboratories..FE.AURobert Elz.AIDepartment of Computer ScienceUniversity of Melbourne,Parkville,Victoria,Australia..AB.PPIn most computing environments, disc space is notinfinite.The disc quota system provides a mechanismto control usage of disc space, on anindividual basis..PPQuotas may be set for each individual user, on any, orall filesystems..PPThe quota system will warn users when theyexceed their allotted limit, but allow someextra space for current work.Repeatedly remaining over quota at logout,will cause a fatal over quota condition eventually..PPThe quota system is an optional part of\s-2VMUNIX\s0 that may be included when thesystem is configured..AE.NH 1Users' view of disc quotas.PPTo most users, disc quotas will either be of no concern,or a fact of life that cannot be avoided.The\fIquota\fP\|(1)command will provide information on any disc quotasthat may have been imposed upon a user..PPThere are two individual possible quotas that may beimposed, usually if one is, both will be.A limit can be set on the amount of space a usercan occupy, and there may be a limit on the numberof files (inodes) he can own..PP.I Quotaprovides information on the quotas that havebeen set by the system administrators, in eachof these areas, and current usage..PPThere are four numbers for each limit, the currentusage, soft limit (quota), hard limit, and numberof remaining login warnings.The soft limit is the number of 1K blocks (or files)that the user is expected to remain below.Each time the user's usage goes past this limit,he will be warned.The hard limit cannot be exceeded.If a user's usage reaches this number, furtherrequests for space (or attempts to create a file)will fail with an EDQUOT error, and the first timethis occurs, a message will be written to the user'sterminal.Only one message will be output, until space occupiedis reduced below the limit, and reaches it again,in order to avoid continual noise from thoseprograms that ignore write errors..PPWhenever a user logs in with a usage greater thanhis soft limit, he will be warned, and his loginwarning count decremented.When he logs in under quota, the counter is resetto its maximum value (which is a system configurationparameter, that is typically 3).If the warning count should ever reach zero (causedby three successive logins over quota), theparticular limit that has been exceeded will be treatedas if the hard limit has been reached, and nomore resources will be allocated to the user.The \fBonly\fP way to reset this condition isto reduce usage below quota, then log in again..NH 2 Surviving when quota limit is reached.PPIn most cases, the only way to recover from overquota conditions, is to abort whatever activity was in progresson the filesystem that has reached its limit, removesufficient files to bring the limit back below quota,and retry the failed program..PPHowever, if you are in the editor and a write failsbecause of an over quota situation, that is nota suitable course of action, as it is most likelythat initially attempting to write the filewill have truncated its previous contents, so shouldthe editor be aborted without correctly writing thefile not only will the recent changes be lost, butpossibly much, or even all, of the datathat previously existed..PPThere are several possible safe exits for a usercaught in this situation.He may use the editor \fB!\fP shell escape command toexamine his file space, and remove surplus files.Alternatively, using \fIcsh\fP, he may suspend theeditor, remove some files, then resume it.A third possibility, is to write the file tosome other filesystem (perhaps to a file on /tmp)where the user's quota has not been exceeded.Then after rectifying the quota situation,the file can be moved back to the filesystemit belongs on..NH 1Administering the quota system.PPTo set up and establish the disc quota system,there are several steps necessary to be performedby the system administrator..PPFirst, the system must be configured to includethe disc quota sub-system.This is done by including the line:.DSoptions QUOTA.DEin the system configuration file, then running\fIconfig\fP\|(8)followed by a system configuration\s-3\u*\d\s0..FS* See also the document ``Building 4.2BSD UNIX Systems with Config''..FE.PPSecond, a decision as to what filesystems need to havequotas applied needs to be made.Usually, only filesystems that house users' home directories,or other user files, will need to be subjected tothe quota system, though it may also prove useful toalso include \fB/usr\fR.If possible, \fB/tmp\fP should usually be free of quotas..PPHaving decided on which filesystems quotas need to beset upon, the administrator should then allocate theavailable space amongst the competing needs. How thisshould be done is (way) beyond the scope of this document..PPThen, the\fIedquota\fP\|(8)command can be used to actually set the limits desired uponeach user. Where a number of users are to be given thesame quotas (a common occurrence) the \fB\-p\fP switchto edquota will allow this to be easily accomplished..PPOnce the quotas are set, ready to operate, the systemmust be informed to enforce quotas on the desired filesystems.This is accomplished with the\fIquotaon\fP\|(8)command..I Quotaonwill either enable quotas for a particular filesystem, orwith the \fB\-a\fP switch, will enable quotas for eachfilesystem indicated in \fB/etc/fstab\fP as using quotas.See\fIfstab\fP\|(5)for details.Most sites using the quota system, will include theline.DS C/etc/quotaon -a.DEin \fB/etc/rc.local\fP..PPShould quotas need to be disabled, the\fIquotaoff\fP(8)command will do that, however, should the filesystem beabout to be dismounted, the\fIumount\fP\|(8)command will disable quotas immediately before thefilesystem is unmounted.This is actually an effect of the\fIumount\fP\|(2)system call, and it guarantees that the quota systemwill not be disabled if the umount would failbecause the filesystem is not idle..PPPeriodically (certainly after each reboot, and when quotasare first enabled for a filesystem), the records retainedin the quota file should be checked for consistency withthe actual number of blocks and files allocated tothe user.The\fIquotacheck\fP\|(8)command can be used to accomplish this.It is not necessary to dismount the filesystem, or disablethe quota system to run this command, though onactive filesystems inaccurate results may occur.This does no real harm in most cases, another run of.I quotacheckwhen the filesystem is idle will certainly correct any inaccuracy..PPThe super-user may use the\fIquota\fP\|(1)command to examine the usage and quotas of any user, andthe\fIrepquota\fP\|(8)command may be used to check the usages and limits forall users on a filesystem..NH 1Some implementation detail..PPDisc quota usage and information is stored in a file on thefilesystem that the quotas are to be applied to.Conventionally, this file is \fBquotas\fR in the root ofthe filesystem.While this name is not known to the system in any way,several of the user level utilities "know" it, andchoosing any other name would not be wise..PPThe data in the file comprises an array of structures, indexedby uid, one structure for each user on the system (whetherthe user has a quota on this filesystem or not).If the uid space is sparse, then the file may have holesin it, which would be lost by copying, so it is best toavoid this..PPThe system is informed of the existence of the quotafile by the\fIsetquota\fP\|(2)system call.It then reads the quota entries for each user currentlyactive, then for any files open owned by users whoare not currently active.Each subsequent open of a file on the filesystem, willbe accompanied by a pairing with its quota information.In most cases this information will be retained in core,either because the user who owns the file is running someprocess, because other files are open owned by the sameuser, or because some file (perhaps this one) was recentlyaccessed.In memory, the quota information is kept hashed by user-idand filesystem, and retained in an LRU chain so recentlyreleased data can be easily reclaimed.Information about those users whose last process hasrecently terminated is also retained in this way..PPEach time a block is accessed or released, and each time an inodeis allocated or freed, the quota system gets toldabout it, and in the case of allocations, gets theopportunity to object..PPMeasurements have shownthat the quota code uses a very small percentage of the systemcpu time consumed in writing a new block to disc..NH 1Acknowledgments.PPThe current disc quota system is loosely based upon a veryearly scheme implemented at the University of New SouthWales, and Sydney University in the mid 70's. That systemimplemented a single combined limit for both files and blockson all filesystems..PPA later system was implemented at the University of Melbourneby the author, but was not kept highly accurately, eg:chown's (etc) did not affect quotas, nor did i/o to a fileother than one owned by the instigator..PPThe current system has been running (with only minor modifications)since January 82 at Melbourne.It is actually just a small part of a much broader resourcecontrol scheme, which is capable of controlling almostanything that is usually uncontrolled in unix. The restof this is, as yet, still in a state where it is far toosubject to change to be considered for distribution..PPFor the 4.2BSD release, much work has been done to cleanup and sanely incorporate the quota code by Sam Leffler andKirk McKusick at The University of California at Berkeley.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -