⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quotas.html

📁 FreeBSD安装说明概述 FreeBSD 提供了一个以文字为主
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>File System Quotas</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手册" href="index.html" /><link rel="UP" title="Storage" href="disks.html" /><link rel="PREVIOUS" title="File System Snapshots" href="snapshots.html" /><link rel="NEXT" title="Encrypting Disk Partitions" href="disks-encrypting.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD 使用手册</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="snapshots.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 12. Storage</td><td width="10%" align="right" valign="bottom"><a href="disks-encrypting.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="QUOTAS" name="QUOTAS">12.12. File System Quotas</a></h1><p>Quotas are an optional feature of the operating system that allow you to limit theamount of disk space and/or the number of files a user or members of a group may allocateon a per-file system basis. This is used most often on timesharing systems where it isdesirable to limit the amount of resources any one user or group of users may allocate.This will prevent one user or group of users from consuming all of the available diskspace.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN18378" name="AEN18378">12.12.1. Configuring Your System toEnable Disk Quotas</a></h2><p>Before attempting to use disk quotas, it is necessary to make sure that quotas areconfigured in your kernel. This is done by adding the following line to your kernelconfiguration file:</p><pre class="PROGRAMLISTING">options QUOTA</pre><p>The stock <tt class="FILENAME">GENERIC</tt> kernel does not have this enabled bydefault, so you will have to configure, build and install a custom kernel in order to usedisk quotas. Please refer to <a href="kernelconfig.html">Chapter 9</a> for moreinformation on kernel configuration.</p><p>Next you will need to enable disk quotas in <tt class="FILENAME">/etc/rc.conf</tt>.This is done by adding the line:</p><pre class="PROGRAMLISTING">enable_quotas="YES"</pre><p>For finer control over your quota startup, there is an additional configurationvariable available. Normally on bootup, the quota integrity of each file system ischecked by the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">quotacheck</span>(8)</span> program. The <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">quotacheck</span>(8)</span> facilityinsures that the data in the quota database properly reflects the data on the filesystem. This is a very time consuming process that will significantly affect the timeyour system takes to boot. If you would like to skip this step, a variable in <ttclass="FILENAME">/etc/rc.conf</tt> is made available for the purpose:</p><pre class="PROGRAMLISTING">check_quotas="NO"</pre><p>If you are running FreeBSD prior to 3.2-RELEASE, the configuration is simpler, andconsists of only one variable. Set the following in your <ttclass="FILENAME">/etc/rc.conf</tt>:</p><pre class="PROGRAMLISTING">check_quotas="YES"</pre><p>Finally you will need to edit <tt class="FILENAME">/etc/fstab</tt> to enable diskquotas on a per-file system basis. This is where you can either enable user or groupquotas or both for all of your file systems.</p><p>To enable per-user quotas on a file system, add the <varclass="OPTION">userquota</var> option to the options field in the <ttclass="FILENAME">/etc/fstab</tt> entry for the file system you want to enable quotas on.For example:</p><pre class="PROGRAMLISTING">/dev/da1s2g   /home    ufs rw,userquota 1 2</pre><p>Similarly, to enable group quotas, use the <var class="OPTION">groupquota</var> optioninstead of <var class="OPTION">userquota</var>. To enable both user and group quotas,change the entry as follows:</p><pre class="PROGRAMLISTING">/dev/da1s2g    /home    ufs rw,userquota,groupquota 1 2</pre><p>By default, the quota files are stored in the root directory of the file system withthe names <tt class="FILENAME">quota.user</tt> and <tt class="FILENAME">quota.group</tt>for user and group quotas respectively. See <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">fstab</span>(5)</span> for more information. Even though the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">fstab</span>(5)</span> manual page saysthat you can specify an alternate location for the quota files, this is not recommendedbecause the various quota utilities do not seem to handle this properly.</p><p>At this point you should reboot your system with your new kernel. <ttclass="FILENAME">/etc/rc</tt> will automatically run the appropriate commands to createthe initial quota files for all of the quotas you enabled in <ttclass="FILENAME">/etc/fstab</tt>, so there is no need to manually create any zero lengthquota files.</p><p>In the normal course of operations you should not be required to run the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">quotacheck</span>(8)</span>, <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">quotaon</span>(8)</span>, or <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">quotaoff</span>(8)</span> commandsmanually. However, you may want to read their manual pages just to be familiar with theiroperation.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN18435" name="AEN18435">12.12.2. Setting Quota Limits</a></h2><p>Once you have configured your system to enable quotas, verify that they really areenabled. An easy way to do this is to run:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">quota -v</kbd></pre><p>You should see a one line summary of disk usage and current quota limits for each filesystem that quotas are enabled on.</p><p>You are now ready to start assigning quota limits with the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">edquota</span>(8)</span> command.</p><p>You have several options on how to enforce limits on the amount of disk space a useror group may allocate, and how many files they may create. You may limit allocationsbased on disk space (block quotas) or number of files (inode quotas) or a combination ofboth. Each of these limits are further broken down into two categories: hard and softlimits.</p><p>A hard limit may not be exceeded. Once a user reaches his hard limit he may not makeany further allocations on the file system in question. For example, if the user has ahard limit of 500 blocks on a file system and is currently using 490 blocks, the user canonly allocate an additional 10 blocks. Attempting to allocate an additional 11 blockswill fail.</p><p>Soft limits, on the other hand, can be exceeded for a limited amount of time. Thisperiod of time is known as the grace period, which is one week by default. If a userstays over his or her soft limit longer than the grace period, the soft limit will turninto a hard limit and no further allocations will be allowed. When the user drops backbelow the soft limit, the grace period will be reset.</p><p>The following is an example of what you might see when you run the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">edquota</span>(8)</span> command. Whenthe <span class="CITEREFENTRY"><span class="REFENTRYTITLE">edquota</span>(8)</span>command is invoked, you are placed into the editor specified by the <ttclass="ENVAR">EDITOR</tt> environment variable, or in the <b class="APPLICATION">vi</b>editor if the <tt class="ENVAR">EDITOR</tt> variable is not set, to allow you to edit thequota limits.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">edquota -u test</kbd></pre><pre class="PROGRAMLISTING">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)</pre><p>You will normally see two lines for each file system that has quotas enabled. One linefor the block limits, and one line for inode limits. Simply change the value you wantupdated to modify the quota limit. For example, to raise this user's block limit from asoft limit of 50 and a hard limit of 75 to a soft limit of 500 and a hard limit of 600,change:</p><pre class="PROGRAMLISTING">/usr: blocks in use: 65, limits (soft = 50, hard = 75)</pre><p>to:</p><pre class="PROGRAMLISTING"> /usr: blocks in use: 65, limits (soft = 500, hard = 600)</pre><p>The new quota limits will be in place when you exit the editor.</p><p>Sometimes it is desirable to set quota limits on a range of UIDs. This can be done byuse of the <var class="OPTION">-p</var> option on the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">edquota</span>(8)</span> command. First, assign the desired quotalimit to a user, and then run <tt class="COMMAND">edquota -p protouserstartuid-enduid</tt>. For example, if user <tt class="USERNAME">test</tt> has the desiredquota limits, the following command can be used to duplicate those quota limits for UIDs10,000 through 19,999:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">edquota -p test 10000-19999</kbd></pre><p>For more information see <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">edquota</span>(8)</span> manual page.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN18489" name="AEN18489">12.12.3. Checking Quota Limits andDisk Usage</a></h2><p>You can use either the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">quota</span>(1)</span> or the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">repquota</span>(8)</span> commands to check quota limits and diskusage. The <span class="CITEREFENTRY"><span class="REFENTRYTITLE">quota</span>(1)</span>command can be used to check individual user or group quotas and disk usage. A user mayonly examine his own quota, and the quota of a group he is a member of. Only thesuper-user may view all user and group quotas. The <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">repquota</span>(8)</span> command can be used to get a summary ofall quotas and disk usage for file systems with quotas enabled.</p><p>The following is some sample output from the <tt class="COMMAND">quota -v</tt> commandfor a user that has quota limits on two file systems.</p><pre class="PROGRAMLISTING">Disk quotas for user test (uid 1002):     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace           /usr      65*     50      75   5days       7      50      60       /usr/var       0      50      75               0      50      60</pre><p>On the <tt class="FILENAME">/usr</tt> file system in the above example, this user iscurrently 15 blocks over the soft limit of 50 blocks and has 5 days of the grace periodleft. Note the asterisk <var class="LITERAL">*</var> which indicates that the user iscurrently over his quota limit.</p><p>Normally file systems that the user is not using any disk space on will not show up inthe output from the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">quota</span>(1)</span> command, even if he has a quota limitassigned for that file system. The <var class="OPTION">-v</var> option will display thosefile systems, such as the <tt class="FILENAME">/usr/var</tt> file system in the aboveexample.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN18521" name="AEN18521">12.12.4. Quotas over NFS</a></h2><p>Quotas are enforced by the quota subsystem on the NFS server. The <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">rpc.rquotad</span>(8)</span> daemonmakes quota information available to the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">quota</span>(1)</span> command on NFS clients, allowing users onthose machines to see their quota statistics.</p><p>Enable <tt class="COMMAND">rpc.rquotad</tt> in <ttclass="FILENAME">/etc/inetd.conf</tt> like so:</p><pre class="PROGRAMLISTING">rquotad/1      dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad</pre><p>Now restart <tt class="COMMAND">inetd</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">kill -HUP `cat /var/run/inetd.pid`</kbd></pre></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="snapshots.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="disks-encrypting.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">File System Snapshots</td><td width="34%" align="center" valign="top"><a href="disks.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Encrypting Disk Partitions</td></tr></table></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -