232 lines
10 KiB
Text
232 lines
10 KiB
Text
<!--
|
|
The FreeBSD Documentation Project
|
|
|
|
$Id: chapter.sgml,v 1.9 1999-06-15 20:24:54 mpp Exp $
|
|
-->
|
|
|
|
<chapter id="quotas">
|
|
<title>Disk Quotas</title>
|
|
|
|
<para><emphasis>Contributed by &a.mpp;. 26 February
|
|
1996</emphasis></para>
|
|
|
|
<para>Quotas are an optional feature of the operating system that allow you
|
|
to limit the amount of disk space and/or the number of files a user, or
|
|
members of a group, may allocate on a per-file system basis. This is used
|
|
most often on timesharing systems where it is desirable to limit the
|
|
amount of resources any one user or group of users may allocate. This
|
|
will prevent one user from consuming all of the available disk
|
|
space.</para>
|
|
|
|
<sect1>
|
|
<title>Configuring Your System to Enable Disk Quotas</title>
|
|
|
|
<para>Before attempting to use disk quotas it is necessary to make sure
|
|
that quotas are configured in your kernel. This is done by adding the
|
|
following line to your kernel configuration file:</para>
|
|
|
|
<programlisting>
|
|
options QUOTA</programlisting>
|
|
|
|
<para>The stock <filename>GENERIC</filename> kernel does not have this
|
|
enabled by default, so you will have to configure, build and install a
|
|
custom kernel in order to use disk quotas. Please refer to the <link
|
|
linkend="kernelconfig">Configuring the FreeBSD Kernel</link> section
|
|
for more information on kernel configuration.</para>
|
|
|
|
<para>Next you will need to enable disk quotas in
|
|
<filename>/etc/sysconfig</filename>. This is done by changing the line:
|
|
|
|
<programlisting>
|
|
quotas=NO</programlisting>
|
|
|
|
to:
|
|
|
|
<programlisting>
|
|
quotas=YES</programlisting></para>
|
|
|
|
<para>If you are running FreeBSD 2.2.2 or later, the configuration file
|
|
will be <filename>/etc/rc.conf</filename> instead and the variable name
|
|
changed to:</para>
|
|
|
|
<programlisting>
|
|
check_quotas=YES</programlisting>
|
|
|
|
<para>Finally you will need to edit <filename>/etc/fstab</filename> 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.</para>
|
|
|
|
<para>To enable per-user quotas on a file system, add the
|
|
<literal>userquota</literal> option to the options field in the
|
|
<filename>/etc/fstab</filename> entry for the file system you want to to
|
|
enable quotas on. For example:</para>
|
|
|
|
<programlisting>
|
|
/dev/da1s2g /home ufs rw,userquota 1 2</programlisting>
|
|
|
|
<para>Similarly, to enable group quotas, use the
|
|
<literal>groupquota</literal> option instead of the
|
|
<literal>userquota</literal> keyword. To enable both user and group
|
|
quotas, change the entry as follows:</para>
|
|
|
|
<programlisting>
|
|
/dev/da1s2g /home ufs rw,userquota,groupquota 1 2</programlisting>
|
|
|
|
<para>By default the quota files are stored in the root directory of the
|
|
file system with the names <filename>quota.user</filename> and
|
|
<filename>quota.group</filename> for user and group quotas respectively.
|
|
See <command>man fstab</command> for more information. Even though that
|
|
man page says that you can specify an alternate location for the quota
|
|
files, this is not recommended since all of the various quota utilities
|
|
do not seem to handle this properly.</para>
|
|
|
|
<para>At this point you should reboot your system with your new kernel.
|
|
<filename>/etc/rc</filename> will automatically run the appropriate
|
|
commands to create the initial quota files for all of the quotas you
|
|
enabled in <filename>/etc/fstab</filename>, so there is no need to
|
|
manually create any zero length quota files.</para>
|
|
|
|
<para>In the normal course of operations you should not be required to run
|
|
the <command>quotacheck</command>, <command>quotaon</command>, or
|
|
<command>quotaoff</command> commands manually. However, you may want to
|
|
read their man pages just to be familiar with their operation.</para>
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>Setting Quota Limits</title>
|
|
|
|
<para>Once you have configured your system to enable quotas, verify that
|
|
they really are enabled. An easy way to do this is to run</para>
|
|
|
|
<screen>&prompt.root; <userinput>quota -v</userinput></screen>
|
|
|
|
<para>You should see a one line summary of disk usage and current quota
|
|
limits for each file system that quotas are enabled on.</para>
|
|
|
|
<para>You are now ready to start assigning quota limits with the
|
|
<command>edquota</command> command.</para>
|
|
|
|
<para>You have several options on how to enforce limits on the amount of
|
|
disk space a user or group may allocate, and how many files they may
|
|
create. You may limit allocations based on disk space (block quotas) or
|
|
number of files (inode quotas) or a combination of both. Each of these
|
|
limits are further broken down into two categories: hard and soft
|
|
limits.</para>
|
|
|
|
<para>A hard limit may not be exceeded. Once a user reaches their hard
|
|
limit they may not make any further allocations on the file system in
|
|
question. For example, if the user has a hard limit of 500 blocks on a
|
|
file system and is currently using 490 blocks, the user can only
|
|
allocate an additional 10 blocks. Attempting to allocate an additional
|
|
11 blocks will fail.</para>
|
|
|
|
<para>Soft limits on the other hand can be exceeded for a limited amount
|
|
of time. This period of time is known as the grace period, which is one
|
|
week by default. If a user stays over his or her soft limit longer than
|
|
their grace period, the soft limit will turn into a hard limit and no
|
|
further allocations will be allowed. When the user drops back below the
|
|
soft limit, the grace period will be reset.</para>
|
|
|
|
<para>The following is an example of what you might see when you run
|
|
then <command>edquota</command> command. When the
|
|
<command>edquota</command> command is invoked, you are placed into the
|
|
editor specified by the <envar>EDITOR</envar> environment variable, or
|
|
in the <command>vi</command> editor if the <envar>EDITOR</envar>
|
|
variable is not set, to allow you to edit the quota limits.</para>
|
|
|
|
<screen>&prompt.root; <userinput>edquota -u test</userinput></screen>
|
|
|
|
<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)</programlisting>
|
|
|
|
<para>You will normally see two lines for each file system that has quotas
|
|
enabled. One line for the block limits, and one line for inode limits.
|
|
Simply change the value you want updated to modify the quota limit. For
|
|
example, to raise this users block limit from a soft limit of 50 and a
|
|
hard limit of 75 to a soft limit of 500 and a hard limit of 600, change:
|
|
<programlisting> /usr: blocks in use: 65, limits (soft = 50, hard =
|
|
75)</programlisting> to: <programlisting> /usr: blocks in use: 65,
|
|
limits (soft = 500, hard = 600)</programlisting></para>
|
|
|
|
<para>The new quota limits will be in place when you exit the
|
|
editor.</para>
|
|
|
|
<para>Sometimes it is desirable to set quota limits on a range of uids.
|
|
This can be done by use of the <option>-p</option> option on the
|
|
<command>edquota</command> command. First, assign the desired quota
|
|
limit to a user, and then run <command>edquota -p protouser
|
|
startuid-enduid</command>. For example, if user
|
|
<username>test</username> has the desired quota limits, the following
|
|
command can be used to duplicate those quota limits for uids 10,000
|
|
through 19,999:</para>
|
|
|
|
<screen>&prompt.root; <userinput>edquota -p test 10000-19999</userinput></screen>
|
|
|
|
<para>The ability to specify uid ranges was added to the system after 2.1
|
|
was released. If you need this feature on a 2.1 system, you will need
|
|
to obtain a newer copy of edquota.</para>
|
|
|
|
<para>See <command>man edquota</command> for more detailed
|
|
information.</para>
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>Checking Quota Limits and Disk Usage</title>
|
|
|
|
<para>You can use either the <command>quota</command> or the
|
|
<command>repquota</command> commands to check quota limits and disk
|
|
usage. The <command>quota</command> command can be used to check
|
|
individual user and group quotas and disk usage. Only the super-user
|
|
may examine quotas and usage for other users, or for groups that they
|
|
are not a member of. The <command>repquota</command> command can be
|
|
used to get a summary of all quotas and disk usage for file systems with
|
|
quotas enabled.</para>
|
|
|
|
<para>The following is some sample output from the <command>quota
|
|
-v</command> command for a user that has quota limits on two file
|
|
systems.</para>
|
|
|
|
|
|
<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</programlisting>
|
|
|
|
<para>On the <filename>/usr</filename> file system in the above example
|
|
this user is currently 15 blocks over their soft limit of 50 blocks and
|
|
has 5 days of their grace period left. Note the asterisk
|
|
<literal>*</literal> which indicates that the user is currently over
|
|
their quota limit.</para>
|
|
|
|
<para>Normally file systems that the user is not using any disk space on
|
|
will not show up in the output from the <command>quota</command>
|
|
command, even if they have a quota limit assigned for that file system.
|
|
The <option>-v</option> option will display those file systems, such as
|
|
the <filename>/usr/var</filename> file system in the above
|
|
example.</para>
|
|
</sect1>
|
|
|
|
<sect1>
|
|
<title>* Quotas over NFS</title>
|
|
|
|
<para>This section is still under development.</para>
|
|
</sect1>
|
|
</chapter>
|
|
|
|
<!--
|
|
Local Variables:
|
|
mode: sgml
|
|
sgml-declaration: "../chapter.decl"
|
|
sgml-indent-data: t
|
|
sgml-omittag: nil
|
|
sgml-always-quote-attributes: t
|
|
sgml-parent-document: ("../handbook.sgml" "part" "chapter")
|
|
End:
|
|
-->
|
|
|