home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / quota.txt < prev    next >
Text File  |  1997-07-07  |  8KB  |  219 lines

  1.  
  2. How To Enable Quota on Linux
  3.  
  4. Last updated: Sat Jul 27 21:04:38 PDT 1996
  5.  
  6. Preamble: This document is copylefted by Albert M.C. Tam (bertie@scn.org).
  7. Permission to use, copy, distribute this document for non-commerical
  8. purposes is hereby granted, provided that the author's / editor's name and
  9. this notice appear in all copies and/or supporting documents; that this
  10. document is not modified. This document is distributed in hope that it will
  11. be useful, but WITHOUT ANY WARRANTY, either expressed or implied. While
  12. every effort has been taken to ensure the accuracy of the information
  13. documented herein, the author / editor / maintainer assumes NO
  14. RESPONSIBILITY for errors, or for damages results for the use of the
  15. information documented herein.
  16.  
  17. This document describes how to enable file system quota on a Linux host,
  18. assigning quota for users, as well as the usage of miscellaneous quota
  19. commands. It is intended for users running kernel 2.x (tested on 2.0.7).
  20. Users with older kernels are recommended to upgrade.
  21.  
  22. Feel free to send any feedback or comments to bertie@scn.org if you find an
  23. error, or if any information is missing. I appreciate it!
  24.  
  25. ----------------------------------------------------------------------------
  26.  
  27. What is Quota?
  28.  
  29. Quota allows you to specify limits on two aspects of disk storage: the
  30. number of inodes a user may possess; and the number of disk blocks that may
  31. be allocated to a user.
  32.  
  33. The idea behind quota is that users are forced to stay under their disk
  34. comsumption limit most of the time, taking away their ability to comsume
  35. unlimited disk space on a system.
  36.  
  37. Current Status of Quota on Linux
  38.  
  39. Quota support has been integrated into since kernel version 1.3.8x I heard,
  40. and it is in the 2.0 release of the kernel as well. If your system doesn't
  41. support quota, I recommend an upgrade.
  42.  
  43. Currently, quota works for ext2 type file system only.
  44.  
  45. Requirements for Using Quota on Linux
  46.  
  47. Kernel
  48.  
  49. The 2.x kernel source is available from
  50.  
  51.      ftp://tsx-11.mit.edu/pub/linux/sources/system/v2.0/
  52.  
  53. Quota software
  54.  
  55. Depending on the Linux distribution you have, you may, or may not have the
  56. quota softwares installed on your system. The quota software source is
  57. available from
  58.  
  59.      ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linus/subsystems/quota/all.tar.gz.
  60.  
  61. ----------------------------------------------------------------------------
  62.  
  63. Quota Setup on Linux - Part I: The Configuration
  64.  
  65. 1. Reconfigure your kernel
  66.  
  67. Reconfigure your kernel and add quota support by typing y to:
  68.  
  69.      Quota support (CONFIG_QUOTA) [n] y
  70.  
  71. 2. Compile and install the quota softwares
  72.  
  73. The quota software source is available from
  74.  
  75.      ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linus/subsystems/quota/all.tar.gz
  76.  
  77. While the quota software package I mentioned earlier has already been ported
  78. to Linux, and should compile on all Linux systems running 2.x kernels; you
  79. may run into problems where the C compiler complains about some undefined
  80. MNTOPT constants. If that happens, you will need to copy its mntent.h over
  81. to /usr/include/mntent.h to get quota to compile.
  82.  
  83. 3. Modify your system init script to check quota and turn on quota at boot
  84. time
  85.  
  86. Here's an example:
  87.  
  88.         # Check quota and then turn quota on.
  89.         if [ -x /usr/sbin/quotacheck ]
  90.         then
  91.                 echo "Checking quotas. This may take some time."
  92.                 /usr/sbin/quotacheck -avug
  93.                 echo " Done."
  94.         fi
  95.  
  96.         if [ -x /usr/sbin/quotaon ]
  97.         then
  98.                 echo "Turning on quota."
  99.                 /usr/sbin/quotaon -avug
  100.         fi
  101.  
  102. The golden rule is that *always* turn quota on *after* your file systems in
  103. /etc/fstab have been mounted, or quota will fail to work. I recommend
  104. turning quota on at the end of your system init script, or, if you like,
  105. right after the part where file systems are mounted in your system init
  106. script.
  107.  
  108. 4. Modify /etc/fstab
  109.  
  110. Partitions that you have not yet enabled quota normally look something like:
  111.  
  112.         /dev/hda1       /       ext2    defaults        1       1
  113.         /dev/hda2       /usr    ext2    defaults        1       1
  114.  
  115. To add quota to the file system, add "usrquota" to the fourth field
  116. containing the word "defaults".
  117.  
  118.         /dev/hda1       /       ext2    defaults        1       1
  119.         /dev/hda2       /usr    ext2    defaults,usrquota       1       1
  120.  
  121. 5. Create quota record "quota.user"
  122.  
  123. This quota record file, quota.user, should be owned by root, and read-write
  124. permission for root and none for anybody else.
  125.  
  126. Login as root. Go to the base of the partition you wish to enable quota, and
  127. create quota.user by doing:
  128.  
  129.         touch /partition/quota.user
  130.         chmod 600 /partition/quota.user
  131.  
  132. 6. Reboot
  133.  
  134. Now reboot system for the changes you have made to take effect.
  135.  
  136. Also note that subsequent partitions you wish to enable quota in the future
  137. only require step 4, 5, and 6.
  138.  
  139. Quota Setup on Linux - Part II: Assigning Quota for Users
  140.  
  141. This operation is performed with the edquota command. For example, the
  142. command "edquota bob" will take you into vi (or editor specified in your
  143. $EDITOR environment variable) to edit quota for user "bob" on each partition
  144. that has quota enabled:
  145.  
  146.         Quotas for user bob:
  147.         /dev/hda2: blocks in use: 2594, limits (soft = 5120, hard = 6400)
  148.                 inodes in use: 356, limits (soft = 1000, hard = 1500)
  149.  
  150. "blocks in use" is the total number of blocks (in kilobytes) a user has
  151. comsumed on a partition.
  152.  
  153. "inodes in use" is the total number of files a user has on a partition.
  154.  
  155. In addition to edquota, there are 3 others terms which you should
  156. familiarize yourself with: Soft Limit, Hard Limit, and Grace Period.
  157.  
  158. Soft Limit
  159.  
  160. Normally, soft limit indicates the maximum amount of disk usage a quota user
  161. has on a partition. But when combined with the grace period, it acts as the
  162. border line, which a quota user is issued warnings about his impending quota
  163. violation when passed.
  164.  
  165. Hard Limit
  166.  
  167. The hard limit only works, when a grace period is set. It specifies the
  168. absolute limit on the disk usage, which a quota user can't go beyond his
  169. hard limit.
  170.  
  171. Grace Period
  172.  
  173. Executed with the command "edquota -t", the grace period is a time limit
  174. before the soft limit is enforced for a quota user. Time units of sec(onds),
  175. min(utes), hour(s), day(s), week(s), and month(s) can be used. This is what
  176. you'll see with the command "edquota -t":
  177.  
  178.         Time units may be: days, hours, minutes, or seconds
  179.         Grace period before enforcing soft limits for users:
  180.         /dev/hda2: block grace period: 0 days, file grace period: 0 days
  181.  
  182. Change the 0 days part to any length of time you feel reasonable. I
  183. personally would choose 7 days (or 1 week).
  184.  
  185. ----------------------------------------------------------------------------
  186.  
  187. Miscellaneous Quota Commands
  188.  
  189. Quotacheck
  190.  
  191. Quotacheck is used to scan a file system for disk usages, and updates the
  192. quota record file "quota.user" to the most recent state. I recommend running
  193. quotacheck periodically at system bootup, or via cronjob every once in a
  194. while (say, 1 week?).
  195.  
  196. Repquota
  197.  
  198. Repquota produces a summarized quota information for a file system. Here is
  199. a sample output repquota gives:
  200.  
  201.         # repquota -a
  202.                                 Block limits               File limits
  203.         User            used    soft    hard  grace    used  soft  hard  grace
  204.         root      --  175419       0       0          14679     0     0
  205.         bin       --   18000       0       0            735     0     0
  206.         uucp      --     729       0       0             23     0     0
  207.         man       --      57       0       0             10     0     0
  208.         user1     --   13046   15360   19200            806  1500  2250
  209.         user2     --    2838    5120    6400            377  1000  1500
  210.  
  211. Quotaon and Quotaoff
  212.  
  213. Quotaon is used to turn on quota accouting; quotaoff to turn it off.
  214. Actually both files are similar. They are executed at system startup and
  215. shutdown.
  216.  
  217.  
  218.  
  219.