This commit is contained in:
gferg 2003-08-09 20:20:46 +00:00
parent e774aa47f7
commit 97d3bbd76e
3 changed files with 305 additions and 278 deletions

View File

@ -266,7 +266,7 @@ Quota</ULink>, <CiteTitle>
Quota mini-HOWTO</CiteTitle> Quota mini-HOWTO</CiteTitle>
</Para><Para> </Para><Para>
<CiteTitle> <CiteTitle>
Updated: April 2002</CiteTitle>. Updated: August 2003</CiteTitle>.
How to enable file system quota on a Linux host, assigning How to enable file system quota on a Linux host, assigning
quota for users and groups, as well as the usage of miscellaneous quota for users and groups, as well as the usage of miscellaneous
quota commands. </Para> quota commands. </Para>

View File

@ -3699,7 +3699,7 @@ on an Intel Linux system. </Para>
Quota</ULink>, Quota</ULink>,
<CiteTitle>Quota mini-HOWTO</CiteTitle> <CiteTitle>Quota mini-HOWTO</CiteTitle>
</Para><Para> </Para><Para>
<CiteTitle>Updated: April 2002</CiteTitle>. <CiteTitle>Updated: August 2003</CiteTitle>.
How to enable file system quota on a Linux host, assigning How to enable file system quota on a Linux host, assigning
quota for users and groups, as well as the usage of miscellaneous quota for users and groups, as well as the usage of miscellaneous
quota commands. </Para> quota commands. </Para>

View File

@ -1,276 +1,303 @@
<!doctype linuxdoc system> <!doctype linuxdoc system>
<article> <article>
<title>Quota mini-HOWTO <title>Quota mini-HOWTO
<author>Ralf van Dooren <tt/r.vdooren@snow.nl/
<date>v0.3, April 2002 <author>Ralf van Dooren <tt/r.vdooren@snow.nl/
<abstract>Preamble: This document is written by Ralf van Dooren (r.vdooren@snow.nl).
Original text and setup of this document is copyleft-ed by Albert M.C. Tam, many thanks to him <date>v0.5, 2003-08-09
for this initial mini-HOWTO. <abstract>
Preamble: This document is written by Ralf van Dooren (r.vdooren@snow.nl).
This document is licensed under the GNU Free Documentation License. Original text and setup of this document is copyleft-ed by Albert M.C. Tam, many thanks to him
<p> for this initial mini-HOWTO.
Permission to use, copy, distribute this document for non-commercial purposes This document is licensed under the GNU Free Documentation License.
is hereby granted, provided that the author's / editor's name and this notice
appear in all copies and/or supporting documents; that this document is not Permission to use, copy, distribute this document for non-commercial purposes
modified. This document is distributed in hope that it will be useful, but is hereby granted, provided that the author's / editor's name and this notice
WITHOUT ANY WARRANTY, either expressed or implied. While every effort has been appear in all copies and/or supporting documents; that this document is not
taken to ensure the accuracy of the information documented herein, the author / modified. This document is distributed in hope that it will be useful, but
editor / maintainer assumes NO RESPONSIBILITY for errors, or for damages results WITHOUT ANY WARRANTY, either expressed or implied. While every effort has been
for the use of the information documented herein. taken to ensure the accuracy of the information documented herein, the author /
<p> editor / maintainer assumes NO RESPONSIBILITY for errors, or for damages results
This document describes how to enable file system quota on a Linux host, for the use of the information documented herein.
assigning quota for users and groups, as well as the usage of miscellaneous <p>
quota commands. It is intended for users running kernel 2.x (recently tested This document describes how to enable file system quota on a Linux host,
on kernel 2.4.17). assigning quota for users and groups, as well as the usage of miscellaneous
<p> quota commands. It is intended for users running kernel 2.x (recently tested
Feel free to send feedbacks or comments to r.vdooren@snow.nl if you find an on kernel 2.4.21).
error, or if any information is missing. I appreciate it. <p>
</abstract> Feel free to send feedbacks or comments to r.vdooren@snow.nl if you find an
<sect>What is Quota? error, or if any information is missing. I appreciate it.
<p> </abstract>
Quota allows you to specify limits on two aspects of disk storage: the
number of inodes a user or a group of users may possess; and the number of <sect>What is quota?
disk blocks that may be allocated to a user or a group of users.
<p> <sect1>What is quota for?
The idea behind quota is that users are forced to stay under their disk
consumption limit, taking away their ability to consume unlimited disk space <p>
on a system. Quota is handled on a per user, per file system basis. If there Quota allows you to specify limits on two aspects of disk storage: the
is more than one file system which a user is expected to create files, then number of inodes a user or a group of users may possess; and the number of
quota must be set for each file system separately. disk blocks that may be allocated to a user or a group of users.
<sect>Current Status of Quota on Linux <p>
<p> The idea behind quota is that users are forced to stay under their disk
consumption limit, taking away their ability to consume unlimited disk space
Currently, there are some major changes in the way quota works. There are two on a system. Quota is handled on a per user, per file system basis. If there
different setups. The tools works the same, but there's a difference in used files. This is more than one file system which a user is expected to create files, then
document describes the setup and operation of the _new_ quota setup. As the new setup quota must be set for each file system separately. Various tools are
of quota is not in the regular kernel source, this setup needs some patching. We will describe this available for you to administer and automate quota policies on your
patching and installation of the linuxquota package. If you already have the quota software installed system.
on your system, you may or may not have to install this patch and package. You can email me if
you have any questions about this. I'll try to include a overview of Linux distro's and it's implications <sect1>Current Status of Quota on Linux
in a later version of this document. <p>
<sect>Requirements for Using Quota on Linux Currently, there are some major changes in the way quota works. There are two
<p> different setups. The tools works the same, but there's a difference in used files. This
<sect1>Kernel document describes the setup and operation of the _new_ quota setup. As the new setup
<p> of quota is not in the regular kernel source, this setup needs some patching. We will describe this
patching and installation of the linuxquota package. If you already have the quota software installed
The 2.x kernel source is available from on your system, you may or may not have to install this patch and package. You can email me if
<code>http://www.kernel.org you have any questions about this. I'll try to include a overview of Linux distro's and it's implications
</code>. Please use an available mirror close to your location to save bandwidth. in a later version of this document.
<sect1>Quota software
<p> <sect>Requirements for quota
<p>
Depending on the Linux distribution you have, you may, or may not have <sect1>Kernel
the quota softwares installed on your system. The most recent version of quota <p>
is available through SourceForge and is in active development. You can reach the
homepage of the quota-development at The 2.x kernel source is available from <url
url="http://www.kernel.org/" name="http://www.kernel.org">
<code>http://www.sourceforge.net/projects/linuxquota Please use an available mirror close to your location to save bandwidth. If
</code> you have a recent version of tar, you can download the .bz2 compressed file.
<p>
<sect>Quota Setup on Linux - Part I: The Configuration Untar the kernel:
<p> <code>
<sect1>Patch the kernel cd /usr/src
tar jxvf /path/to/linux-2.4.21-tar.bz2 - for bzip2 kernel -
<p>Download the patch for your kernel at: tar zxvf /path/to/linux-2.4.21-tar.gz - for gzip kernel -
ln -s /usr/src/linux-2.4.21 /usr/src/linux
<code> </code>
ftp://atrey.karlin.mff.cuni.cz/pub/local/jack/quota/
</code> <sect1>Quota software
<p> <p>
Choose your kernel version and download the patch. Patch your kernel with the 'patch' command.
Depending on the Linux distribution you have, you may, or may not have
<sect1>Reconfigure your kernel the quota softwares installed on your system. The most recent version of quota
<p> is available through SourceForge and is in active development. You can reach the
homepage of the quota-development at <url
Reconfigure your kernel and add quota support by typing y to: url="http://www.sourceforge.net/project/linuxquota"
<code>Quota support (CONFIG_QUOTA) [n] y name="http://www.sourceforge.net/projects/linuxquota" >.
</code>
<sect>Quota setup: installation and configuration
<p>Via `make menuconfig` of `make xconfig` you can find the option to support quota
under the Filesystems-menu. <sect1>Patch the kernel
Make sure the new kernel will be used when rebooting the system. <p>Download the patch for your kernel at:
<sect1>Compile and install the quota softwares <url url="ftp://atrey.karlin.mff.cuni.cz/pub/local/jack/quota/"
<p> name="ftp::/atrey.karlin.mff.cuni.cz/pub/local/jack/quota/" >.
If the quota package is already in your Linux distribution, you don't have to install the quota
software. If the quota package is not available in your Linux distribution, or if you wan't to <p>
install the most recent version, you can download the latest version of the quota software source from Choose your kernel version and download the patch(es). Patch your kernel with the 'patch' command. If there is more than 1 patch for your kernel version, be sure to apply the patches in the correct order.
the location mentioned above.
<p> You can use this script ( I assume the downloaded patches are in /tmp/quota/ and the kernel has been untarred to /usr/src/linux) :
When downloaded do:
<code>$ gzip -dc <downloaded file> | tar xvf <code>
$ cd quota-tools (or whatever directory the software is put in) #!/bin/sh
$ ./configure
$ make gunzip /tmp/quota/*.gz
$ su cd /usr/src/linux
# make install COUNT=`ls -1 /tmp/quota/*.diff | wc -l`
for I in `seq 1 $COUNT`
</code> do
patch -p1 < /tmp/quota/quota-2.4.21-$I-*.diff
<sect1>Modify your system init script to check quota and turn quota on at boot done
time </code>
<p>
<sect1>Reconfigure your kernel
Here's an example: <p>
<code>&num; Check quota and then turn quota on.
if [ -x /usr/sbin/quotacheck ] Reconfigure your kernel and add quota support.
then
echo "Checking quotas. This may take some time." <p>Via `make menuconfig` or `make xconfig` you can find the option to support quota under the Filesystems-menu. You can specify extra options if you need them, like 32-bit UID support.
/usr/sbin/quotacheck -avug
echo " Done." <p>Save the configuration and compile the kernel. Make sure the new kernel will be used when rebooting the system.
fi
if [ -x /usr/sbin/quotaon ] <sect1>Compile and install the quota softwares
then <p>
echo "Turning on quota." To be able to use all the features of the new quota system, you'll probably need to download the new quota-package. Download the new quota software via the URL
/usr/sbin/quotaon -avug provided above.
fi <p>
</code> When downloaded do:
<code>$ gzip -dc <downloaded file> | tar xvf
The golden rule is that always turn quota on after your file systems in $ cd quota-tools (or whatever directory the software is put in)
/etc/fstab have been mounted, otherwise quota will fail to work. I recommend $ ./configure
turning quota on right after the part where file systems are mounted in your system init script. $ make
$ su
<sect1>Modify /etc/fstab # make install
<p>
</code>
Partitions that you have not yet enabled quota normally look something
like: <sect1>Modify your system init script to check quota and turn quota on at boot
<code>/dev/hda1 / ext2 defaults 1 1 time
/dev/hda2 /usr ext2 defaults 1 1 <p>
</code>
Here's an example:
To enable user quota support on a file system, add "usrquota" to the fourth <code>&num; Check quota and then turn quota on.
field containing the word "defaults" (man fstab for details). if [ -x /usr/sbin/quotacheck ]
<code>/dev/hda1 / ext2 defaults 1 1 then
/dev/hda2 /usr ext2 defaults,usrquota 1 1 echo "Checking quotas. This may take some time."
</code> /usr/sbin/quotacheck -avug
echo " Done."
Replace "usrquota" with "grpquota", should you need group quota support fi
on a file system. if [ -x /usr/sbin/quotaon ]
<code>/dev/hda1 / ext2 defaults 1 1 then
/dev/hda2 /usr ext2 defaults,grpquota 1 1 echo "Turning on quota."
</code> /usr/sbin/quotaon -avug
fi
Need both user quota and group quota support on a file system? </code>
<code>/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,usrquota,grpquota 1 1 The golden rule is that always turn quota on after your file systems in
</code> /etc/fstab have been mounted, otherwise quota will fail to work. I recommend
turning quota on right after the part where file systems are mounted in your system init script.
<sect1>Activate the quota system
<p> <sect1>Modify /etc/fstab
To activate the quota software you have to reboot the system for the changes you have made <p>
to take effect. The new kernel with quota support will be loaded and the startup scripts you've
just created will be executed. At first run, quotacheck will generate the appropiate files to maintain Partitions that you have not yet enabled quota normally look something
the quota databases. like:
<code>/dev/hda1 / ext2 defaults 1 1
<sec1>Add quotacheck to crontab /dev/hda2 /usr ext2 defaults 1 1
</code>
<p>
Although quota should work with periodical checks, it sometimes helps to run quotacheck periodically, e.g. weekly. Add the following line to your root's crontab: To enable user quota support on a file system, add "usrquota" to the fourth
<code>0 3 * * 0 /sbin/quotacheck -avug field containing the word "defaults" (man fstab for details).
</code> <code>/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,usrquota 1 1
<sect>Quota Setup on Linux - Part II: Assigning Quota for Users and Groups </code>
<p>
Replace "usrquota" with "grpquota", should you need group quota support
This operation is performed with the edquota command (`man edquota` for details). on a file system.
<code>/dev/hda1 / ext2 defaults 1 1
<sect1>Assigning quota for a particular user /dev/hda2 /usr ext2 defaults,grpquota 1 1
<p> </code>
Here's an example. I have a user with the login id bob on my system. The Need both user quota and group quota support on a file system?
command "edquota -u bob" takes me into vi (or editor specified in my &dollar;EDITOR <code>/dev/hda1 / ext2 defaults 1 1
environment variable) to edit quota for user bob on each partition that has /dev/hda2 /usr ext2 defaults,usrquota,grpquota 1 1
quota enabled: </code>
<code>Quotas for user bob:
/dev/hda3: blocks in use: 2594, limits (soft = 5000, hard = 6500) <sect1>Activate the quota system
inodes in use: 356, limits (soft = 1000, hard = 1500) <p>
</code> To activate the quota software you have to reboot the system for the changes you have made
to take effect. The new kernel with quota support will be loaded and the startup scripts you've
"blocks in use" is the total number of blocks (in kilobytes) a user has just created will be executed. At first run, quotacheck will generate the appropiate files to maintain
consumed on a partition. the quota databases.
"inodes in use" is the total number of inodes a user has consumed on a partition. <sect1>Add quotacheck to crontab
<sect1>Assigning quota for a particular group
<p> <p>
Although quota should work with periodical checks, it sometimes helps to run quotacheck periodically, e.g. weekly. Add the following line to your root's crontab:
Now I have a group games on my system. "edquota -g games" takes me into <code>0 3 * * 0 /sbin/quotacheck -avug
the vi editor again to edit quota for the group games: </code>
<code> Quotas for group games:
/dev/hda4: blocks in use: 5799, limits (soft = 8000, hard = 10000) <sect>Quota setup: tools
inodes in use: 1454, limits (soft = 3000, hard = 4000) <p>
</code>
<sect1>Assigning quota for a bunch of users with the same value This operation is performed with the edquota command (`man edquota` for details).
<p>
<sect1>Assigning quota for a particular user
To rapidly set quotas for, say 100 users, on my system to the same value <p>
as my user bob, I would first edit bob's quota information by hand, then execute:
<code>edquota -p bob `awk -F: '&dollar;3 &gt; 499 {print &dollar;1}' /etc/passwd` Here's an example. I have a user with the login id bob on my system. The
</code> command "edquota -u bob" takes me into vi (or editor specified in my &dollar;EDITOR
environment variable) to edit quota for user bob on each partition that has
assuming that you are using csh, and that you assign your user UID's starting quota enabled:
with 500. <code>Quotas for user bob:
/dev/hda3: blocks in use: 2594, limits (soft = 5000, hard = 6500)
In addition to edquota, there are 3 terms which you should familiarize inodes in use: 356, limits (soft = 1000, hard = 1500)
yourself with: Soft Limit, Hard Limit, and Grace Period. </code>
<sect1>Soft Limit
<p> "blocks in use" is the total number of blocks (in kilobytes) a user has
consumed on a partition.
_Soft limit_ indicates the maximum amount of disk usage a quota user has
on a partition. When combined with grace period, it acts as the border line, "inodes in use" is the total number of inodes a user has consumed on a partition.
which a quota user is issued warnings about his impending quota violation when <sect1>Assigning quota for a particular group
passed. <p>
<sect1>Hard Limit
<p> Now I have a group games on my system. "edquota -g games" takes me into
the vi editor again to edit quota for the group games:
Hard limit works only when grace period is set. It specifies the absolute <code> Quotas for group games:
limit on the disk usage, which a quota user can't go beyond his hard limit. /dev/hda4: blocks in use: 5799, limits (soft = 8000, hard = 10000)
<sect1>Grace Period inodes in use: 1454, limits (soft = 3000, hard = 4000)
<p> </code>
<sect1>Assigning quota for a bunch of users with the same value
Executed with the command "edquota -t", grace period is a time limit before <p>
the soft limit is enforced for a file system with quota enabled. Time units
of sec(onds), min(utes), hour(s), day(s), week(s), and month(s) can be used. To rapidly set quotas for, say 100 users, on my system to the same value
This is what you'll see with the command "edquota -t": as my user bob, I would first edit bob's quota information by hand, then execute:
<code>Time units may be: days, hours, minutes, or seconds <code>edquota -p bob `awk -F: '&dollar;3 &gt; 499 {print &dollar;1}' /etc/passwd`
Grace period before enforcing soft limits for users: </code>
/dev/hda2: block grace period: 0 days, file grace period: 0 days
</code> assuming that you are using csh, and that you assign your user UID's starting
with 500.
Change the 0 days part to any length of time you feel reasonable. I personally
would choose 7 days (or 1 week). In addition to edquota, there are 3 terms which you should familiarize
<sect>Miscellaneous Quota Commands yourself with: Soft Limit, Hard Limit, and Grace Period.
<p> <sect1>Soft Limit
<sect1>Quotacheck <p>
<p>
_Soft limit_ indicates the maximum amount of disk usage a quota user has
Quotacheck is used to scan a file system for disk usages, and updates the on a partition. When combined with grace period, it acts as the border line,
quota record file "aquota.user" to the most recent state. I recommend running which a quota user is issued warnings about his impending quota violation when
quotacheck at system bootup, and via cronjob periodically (say, every week?). passed.
<sect1>Repquota <sect1>Hard Limit
<p> <p>
Repquota produces a summarized quota information for a file system. Here Hard limit works only when grace period is set. It specifies the absolute
is a sample output repquota gives: limit on the disk usage, which a quota user can't go beyond his hard limit.
<code>&num; repquota -a <sect1>Grace Period
Block limits File limits <p>
User used soft hard grace used soft hard grace
root -- 175419 0 0 14679 0 0 Executed with the command "edquota -t", grace period is a time limit before
bin -- 18000 0 0 735 0 0 the soft limit is enforced for a file system with quota enabled. Time units
uucp -- 729 0 0 23 0 0 of sec(onds), min(utes), hour(s), day(s), week(s), and month(s) can be used.
man -- 57 0 0 10 0 0 This is what you'll see with the command "edquota -t":
user1 -- 13046 15360 19200 806 1500 2250 <code>Time units may be: days, hours, minutes, or seconds
user2 -- 2838 5120 6400 377 1000 1500 Grace period before enforcing soft limits for users:
</code> /dev/hda2: block grace period: 0 days, file grace period: 0 days
<sect1>Quotaon and Quotaoff </code>
<p>
Change the 0 days part to any length of time you feel reasonable. I personally
Quotaon is used to turn on quota accounting; quotaoff to turn it off. Actually would choose 7 days (or 1 week).
both files are similar. They are executed at system startup and shutdown. <sect>Miscellaneous Quota Commands
<p>
</article> <sect1>Quotacheck
<p>
Quotacheck is used to scan a file system for disk usages, and updates the
quota record file "aquota.user" to the most recent state. I recommend running
quotacheck at system bootup, and via cronjob periodically (say, every week?).
<sect1>Repquota
<p>
Repquota produces a summarized quota information for a file system. Here
is a sample output repquota gives:
<code>&num; repquota -a
Block limits File limits
User used soft hard grace used soft hard grace
root -- 175419 0 0 14679 0 0
bin -- 18000 0 0 735 0 0
uucp -- 729 0 0 23 0 0
man -- 57 0 0 10 0 0
user1 -- 13046 15360 19200 806 1500 2250
user2 -- 2838 5120 6400 377 1000 1500
</code>
<sect1>Quotaon and Quotaoff
<p>
Quotaon is used to turn on quota accounting; quotaoff to turn it off. Actually
both files are similar. They are executed at system startup and shutdown.
</article>