Move the quotas chapter into the disks chapter.

This commit is contained in:
Jim Mock 2000-03-20 20:59:51 +00:00
parent 2ccbd656fa
commit f1bb87de1d
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=6809
9 changed files with 480 additions and 293 deletions

View file

@ -1,5 +1,5 @@
#
# $FreeBSD: doc/en_US.ISO_8859-1/books/handbook/Makefile,v 1.26 1999/09/06 06:52:44 peter Exp $
# $FreeBSD: doc/en_US.ISO_8859-1/books/handbook/Makefile,v 1.27 2000/03/08 11:12:10 nbm Exp $
#
# Build the FreeBSD Handbook.
#
@ -24,6 +24,7 @@ SRCS+= advanced-networking/chapter.sgml
SRCS+= backups/chapter.sgml
SRCS+= basics/chapter.sgml
SRCS+= bibliography/chapter.sgml
SRCS+= boot/chapter.sgml
SRCS+= contrib/chapter.sgml
SRCS+= cutting-edge/chapter.sgml
SRCS+= disks/chapter.sgml
@ -43,7 +44,6 @@ SRCS+= pgpkeys/chapter.sgml
SRCS+= policies/chapter.sgml
SRCS+= ppp-and-slip/chapter.sgml
SRCS+= printing/chapter.sgml
SRCS+= quotas/chapter.sgml
SRCS+= security/chapter.sgml
SRCS+= serialcomms/chapter.sgml
SRCS+= staff/chapter.sgml

View file

@ -1,7 +1,7 @@
<!--
The FreeBSD Documentation Project
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/book.sgml,v 1.85 2000/03/17 09:59:24 nbm Exp $
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/book.sgml,v 1.86 2000/03/17 10:51:35 nbm Exp $
-->
<!DOCTYPE BOOK PUBLIC "-//FreeBSD//DTD DocBook V3.1-Based Extension//EN" [
@ -89,7 +89,6 @@
&chap.printing;
&chap.disks;
&chap.backups;
&chap.quotas;
&chap.x11;
&chap.l10n;
</part>

View file

@ -6,7 +6,7 @@
Chapters should be listed in the order in which they are referenced.
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/chapters.ent,v 1.6 2000/03/08 11:12:14 nbm Exp $
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/chapters.ent,v 1.7 2000/03/17 10:44:01 nbm Exp $
-->
<!-- Part one -->
@ -23,7 +23,6 @@
<!ENTITY chap.printing SYSTEM "printing/chapter.sgml">
<!ENTITY chap.disks SYSTEM "disks/chapter.sgml">
<!ENTITY chap.backups SYSTEM "backups/chapter.sgml">
<!ENTITY chap.quotas SYSTEM "quotas/chapter.sgml">
<!ENTITY chap.x11 SYSTEM "x11/chapter.sgml">
<!ENTITY chap.l10n SYSTEM "l10n/chapter.sgml">

View file

@ -1,7 +1,7 @@
<!--
The FreeBSD Documentation Project
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/disks/chapter.sgml,v 1.10 2000/03/20 12:38:39 nbm Exp $
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/disks/chapter.sgml,v 1.11 2000/03/20 20:06:25 jim Exp $
-->
<chapter id="disks">
@ -224,27 +224,250 @@
</sect2>
</sect1>
<!-- <sect1>
<title>* Non-traditional Drives</title>
<sect2>
<title>* Zip Drives</title>
<sect1 id="quotas">
<title>Disk Quotas</title>
<para></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>
<sect2>
<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/rc.conf</filename>. This is done by adding the
line:</para>
<programlisting>
enable_quotas=&ldquo;YES&rdquo;</programlisting>
<para>For finer control over your quota startup, there is an
additional configuration variable available. Normally on bootup,
the quota integrity of each file system is checked by the
<command>quotacheck</command> program. The
<command>quotacheck</command> facility insures that the data in
the quota database properly reflects the data on the file system.
This is a very time consuming process that will significantly
affect the time your system takes to boot. If you would like to
skip this step, a variable is made available for the
purpose:</para>
<programlisting>
check_quotas=&ldquo;NO&rdquo;</programlisting>
<para>If you are running FreeBSD prior to 3.2-RELEASE, the
configuration is simpler, and consists of only one variable. Set
the following in your <filename>/etc/rc.conf</filename>:</para>
<programlisting>
check_quotas=&ldquo;YES&rdquo;</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>
</sect2>
<sect2>
<title>* Jaz Drives</title>
<title>Setting Quota Limits</title>
<para></para>
<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:</para>
<programlisting>/usr: blocks in use: 65, limits (soft = 50, hard = 75)</programlisting>
<para>to:</para>
<programlisting> /usr: blocks in use: 65, limits (soft = 500, hard = 600)</programlisting>
<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>See <command>man edquota</command> for more detailed
information.</para>
</sect2>
<sect2>
<title>* Sequest Drives</title>
<title>Checking Quota Limits and Disk Usage</title>
<para></para>
<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>
</sect2>
</sect1> -->
<sect2>
<title>Quotas over NFS</title>
<para>Quotas are enforced by the quota subsystem on the NFS server.
The &man.rpc.rquotad.8; daemon makes quota information available
to the &man.quota.1; command on NFS clients, allowing users on
those machines to see their quota statistics.</para>
<para>Enable <command>rpc.rquotad</command> in
<filename>/etc/inetd.conf</filename> like so:</para>
<programlisting>
rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad</programlisting>
<para>Now restart <command>inetd</command>:</para>
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/inetd.pid`</userinput></screen>
</sect2>
</sect1>
</chapter>
<!--

View file

@ -1,5 +1,5 @@
#
# $FreeBSD: doc/en_US.ISO_8859-1/books/handbook/Makefile,v 1.26 1999/09/06 06:52:44 peter Exp $
# $FreeBSD: doc/en_US.ISO_8859-1/books/handbook/Makefile,v 1.27 2000/03/08 11:12:10 nbm Exp $
#
# Build the FreeBSD Handbook.
#
@ -24,6 +24,7 @@ SRCS+= advanced-networking/chapter.sgml
SRCS+= backups/chapter.sgml
SRCS+= basics/chapter.sgml
SRCS+= bibliography/chapter.sgml
SRCS+= boot/chapter.sgml
SRCS+= contrib/chapter.sgml
SRCS+= cutting-edge/chapter.sgml
SRCS+= disks/chapter.sgml
@ -43,7 +44,6 @@ SRCS+= pgpkeys/chapter.sgml
SRCS+= policies/chapter.sgml
SRCS+= ppp-and-slip/chapter.sgml
SRCS+= printing/chapter.sgml
SRCS+= quotas/chapter.sgml
SRCS+= security/chapter.sgml
SRCS+= serialcomms/chapter.sgml
SRCS+= staff/chapter.sgml

View file

@ -1,7 +1,7 @@
<!--
The FreeBSD Documentation Project
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/book.sgml,v 1.85 2000/03/17 09:59:24 nbm Exp $
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/book.sgml,v 1.86 2000/03/17 10:51:35 nbm Exp $
-->
<!DOCTYPE BOOK PUBLIC "-//FreeBSD//DTD DocBook V3.1-Based Extension//EN" [
@ -89,7 +89,6 @@
&chap.printing;
&chap.disks;
&chap.backups;
&chap.quotas;
&chap.x11;
&chap.l10n;
</part>

View file

@ -6,7 +6,7 @@
Chapters should be listed in the order in which they are referenced.
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/chapters.ent,v 1.6 2000/03/08 11:12:14 nbm Exp $
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/chapters.ent,v 1.7 2000/03/17 10:44:01 nbm Exp $
-->
<!-- Part one -->
@ -23,7 +23,6 @@
<!ENTITY chap.printing SYSTEM "printing/chapter.sgml">
<!ENTITY chap.disks SYSTEM "disks/chapter.sgml">
<!ENTITY chap.backups SYSTEM "backups/chapter.sgml">
<!ENTITY chap.quotas SYSTEM "quotas/chapter.sgml">
<!ENTITY chap.x11 SYSTEM "x11/chapter.sgml">
<!ENTITY chap.l10n SYSTEM "l10n/chapter.sgml">

View file

@ -1,7 +1,7 @@
<!--
The FreeBSD Documentation Project
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/disks/chapter.sgml,v 1.10 2000/03/20 12:38:39 nbm Exp $
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/disks/chapter.sgml,v 1.11 2000/03/20 20:06:25 jim Exp $
-->
<chapter id="disks">
@ -224,27 +224,250 @@
</sect2>
</sect1>
<!-- <sect1>
<title>* Non-traditional Drives</title>
<sect2>
<title>* Zip Drives</title>
<sect1 id="quotas">
<title>Disk Quotas</title>
<para></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>
<sect2>
<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/rc.conf</filename>. This is done by adding the
line:</para>
<programlisting>
enable_quotas=&ldquo;YES&rdquo;</programlisting>
<para>For finer control over your quota startup, there is an
additional configuration variable available. Normally on bootup,
the quota integrity of each file system is checked by the
<command>quotacheck</command> program. The
<command>quotacheck</command> facility insures that the data in
the quota database properly reflects the data on the file system.
This is a very time consuming process that will significantly
affect the time your system takes to boot. If you would like to
skip this step, a variable is made available for the
purpose:</para>
<programlisting>
check_quotas=&ldquo;NO&rdquo;</programlisting>
<para>If you are running FreeBSD prior to 3.2-RELEASE, the
configuration is simpler, and consists of only one variable. Set
the following in your <filename>/etc/rc.conf</filename>:</para>
<programlisting>
check_quotas=&ldquo;YES&rdquo;</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>
</sect2>
<sect2>
<title>* Jaz Drives</title>
<title>Setting Quota Limits</title>
<para></para>
<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:</para>
<programlisting>/usr: blocks in use: 65, limits (soft = 50, hard = 75)</programlisting>
<para>to:</para>
<programlisting> /usr: blocks in use: 65, limits (soft = 500, hard = 600)</programlisting>
<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>See <command>man edquota</command> for more detailed
information.</para>
</sect2>
<sect2>
<title>* Sequest Drives</title>
<title>Checking Quota Limits and Disk Usage</title>
<para></para>
<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>
</sect2>
</sect1> -->
<sect2>
<title>Quotas over NFS</title>
<para>Quotas are enforced by the quota subsystem on the NFS server.
The &man.rpc.rquotad.8; daemon makes quota information available
to the &man.quota.1; command on NFS clients, allowing users on
those machines to see their quota statistics.</para>
<para>Enable <command>rpc.rquotad</command> in
<filename>/etc/inetd.conf</filename> like so:</para>
<programlisting>
rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad</programlisting>
<para>Now restart <command>inetd</command>:</para>
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/inetd.pid`</userinput></screen>
</sect2>
</sect1>
</chapter>
<!--

View file

@ -1,255 +0,0 @@
<!--
The FreeBSD Documentation Project
$FreeBSD: doc/en_US.ISO_8859-1/books/handbook/quotas/chapter.sgml,v 1.13 1999/11/07 01:54:54 chris 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/rc.conf</filename>. This is done by adding the line:
</para>
<programlisting>
enable_quotas=YES</programlisting>
<para>For finer control over your quota startup, there is an additional
configuration variable available. Normally on bootup, the quota integrity
of each file system is checked by the <command>quotacheck</command>
program. The <command>quotacheck</command> facility insures that the
data in the quota database properly reflects the data on the
file system. This is a very time consuming process that will
significantly affect the time your system takes to boot. If you would
like to skip this step, a variable is made available for the purpose:
</para>
<programlisting>
check_quotas=NO</programlisting>
<para>If you are running FreeBSD prior to 3.2-RELEASE, the configuration
is simpler, and consists of only one variable. Set the following in your
<filename>/etc/rc.conf</filename>:</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>Quotas are enforced by the quota subsystem on the NFS server.
The <command>rpc.rquotad(8)</command> daemon makes quota
information available to the <command>quota(1)</command> command
on NFS clients, allowing users on those machines to see their quota
statistics.</para>
<para>Enable <command>rpc.rquotad</command> in
<filename>/etc/inetd.conf</filename> like so:</para>
<programlisting>
rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad</programlisting>
<para>Now restart <command>inetd</command>:</para>
<screen>&prompt.root; <userinput>kill -HUP `cat /var/run/inetd.pid`</userinput></screen>
</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: ("../book.sgml" "part" "chapter")
End:
-->