aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO_8859-1/books/handbook/quotas/chapter.sgml
blob: d82b970be15dd06f7389cd1a1ea316ffe03729b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!--
     The FreeBSD Documentation Project

     $Id: chapter.sgml,v 1.10 1999-08-23 21:24:08 nik 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: ("../book.sgml" "part" "chapter")
     End:
-->