Quick HOWTO : Ch28 : Managing Disk Usage with Quotas
文章出处: |
{{#if: | {{{2}}} | http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch28_:_Managing_Disk_Usage_with_Quotas }} |
点击翻译: |
English {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/af | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Afrikaans| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/af|Afrikaans]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ar | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|العربية| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ar|العربية]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/az | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|azərbaycanca| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/bcc | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|جهلسری بلوچی| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/bg | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|български| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/bg|български]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/br | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|brezhoneg| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/br|brezhoneg]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ca | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|català| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ca|català]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/cs | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|čeština| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/cs|čeština]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/de | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Deutsch| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/de|Deutsch]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/el | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Ελληνικά| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/es | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|español| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/es|español]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/fa | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|فارسی| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/fa|فارسی]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/fi | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|suomi| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/fi|suomi]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/fr | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|français| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/fr|français]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/gu | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|ગુજરાતી| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/he | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|עברית| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/he|עברית]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/hu | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|magyar| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/hu|magyar]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/id | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Bahasa Indonesia| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/it | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|italiano| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/it|italiano]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ja | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|日本語| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ja|日本語]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ko | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|한국어| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ko|한국어]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ksh | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Ripoarisch| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/mr | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|मराठी| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/mr|मराठी]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ms | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Bahasa Melayu| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/nl | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Nederlands| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/nl|Nederlands]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/no | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|norsk| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/no|norsk]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/oc | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|occitan| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/oc|occitan]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/pl | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|polski| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/pl|polski]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/pt | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|português| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/pt|português]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ro | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|română| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ro|română]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/ru | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|русский| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/ru|русский]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/si | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|සිංහල| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/si|සිංහල]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/sq | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|shqip| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/sq|shqip]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/sr | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|српски / srpski| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/sv | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|svenska| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/sv|svenska]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/th | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|ไทย| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/th|ไทย]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/tr | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Türkçe| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/tr|Türkçe]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/vi | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|Tiếng Việt| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/yue | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|粵語| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/yue|粵語]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/zh | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|中文| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/zh|中文]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/zh-hans | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|中文(简体)| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | Quick HOWTO : Ch28 : Managing Disk Usage with Quotas | {{#if: | :}}Quick HOWTO : Ch28 : Managing Disk Usage with Quotas}}/zh-hant | • {{#if: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|中文(繁體)| [[::Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|:Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/zh | | {{#ifexist: Quick HOWTO : Ch28 : Managing Disk Usage with Quotas/zh | | {{#ifeq: {{#titleparts:Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Quick HOWTO : Ch28 : Managing Disk Usage with Quotas|1|-1|}} | zh | | }}
Introduction
You may eventually need to restrict the amount of disk space used on each partition by each user or group of users as your disk drives become filled with data. The disk quota feature of RedHat/Fedora Linux enables you to do this, and the setup is fairly simple.
Setting Up Quotas
For example, your family Linux server is running out of space in the /home filesystem because of an abundance of MP3 downloads.
Enter Single-User Mode
As you'll need to remount the /home filesystem, you make sure that no other users or processes are using it by first entering single-user mode from the console. If you are certain that you're the only user on the system, you might be able to skip this step. Entering single-user mode automatically logs off all users and stops cron jobs, so wait until after hours to do in a business environment. The procedure is quick:
1) Use the who command to see which users are logged in. If there are any, besides yourself, send a message stating that the system is about to shutdown with the wall command:
[root@bigboy tmp]# who root pts/0 Nov 6 14:46 (192-168-1-242.my-site.com) bob pts/0 Nov 6 12:01 (192-168-1-248.my-site.com) bunny pts/0 Nov 6 16:25 (192-168-1-250.my-site.com) [root@bigboy tmp]# wall The system is shutting down now! Broadcast message from root (pts/0) (Sun Nov 7 15:04:27 2004): The system is shutting down now! [root@bigboy tmp]#
2) Log into the VGA console and enter single user mode.
[root@bigboy tmp]# init 1
Simple eh?
Edit Your /etc/fstab File
The /etc/fstab file lists all the partitions that need to be auto-mounted when the system boots. You have to alert Linux that quotas are enabled on the filesystem by editing the /etc/fstab file and modifying the options for the /home directory. You'll need to add the usrquota option. In case you forget the name, the usrquota option is mentioned in the fstab man pages.
The old /etc/fstab looked like
LABEL=/home /home ext3 defaults 1 2
but your new /etc/fstab should be
LABEL=/home /home ext3 defaults,usrquota 1 2
Remount The Filesystem
Editing the /etc/fstab file isn't enough, Linux needs to reread the file to get its instructions for /home. You can do this using the mount command with the -o remount qualifier.
bash-2.05b# mount -o remount /home
Get Out of Single-user Mode
Return to your original run state by using either the exit, init 3 or init 5 commands. Continue to the next step once the system is back to its normal state. You can also use the exit command to return to your default runlevel.
bash-2.05b# exit
Create The Partition Quota Configuration Files
The uppermost directory of the filesystem needs to have an aquota.user file (defines quotas by user) and an aquota.group file (defines quotas by group), or both. The man page for quota lists them at the bottom. In this case just enable per-user quotas for the /home filesystem.
[root@bigboy tmp]# touch /home/aquota.user
[root@bigboy tmp]# chmod 600 /home/aquota.user [root@bigboy tmp]#
Initialize The Quota Table
Editing the /etc/fstab file and remounting the file system only alerted Linux to the fact that the filesystem has quota capabilities. You have to generate a quota table, separate from the aquota files, that lists all the current allocations for each user on the file system. This table will be automatically and transparently updated each time a file is modified. Linux compares the values in this table with the quota limitations that the systems administrator has placed in the aquota files and uses this information to determine whether the user has rights to increased disk usage. You initialize the table with the quotacheck command. Be prepared: You'll get an error the first time you enter the command, because Linux will realize that the aquota file wasn't created using one of the quota commands:
[root@bigboy tmp]# quotacheck -vagum quotacheck: WARNING - Quotafile /home/aquota.user was probably truncated. Can't save quota settings... quotacheck: Scanning /dev/hda3 [/home] done quotacheck: Checked 185 directories and 926 files [root@bigboy tmp]#
Edit The User's Quota Information
Now you need to edit the user's quota information. The edquota command enables you to selectively edit a portion of the aquota.user file on a per-user basis:
[root@bigboy tmp]# edquota -u mp3user
The command will invoke the vi editor.
Disk quotas for user mp3user (uid 503): Filesystem blocks soft hard inodes soft hard /dev/hda3 24 0 0 7 0 0
From here, you can edit a number of fields:
- Blocks: The amount of space in 1K blocks the user is currently using.
- Inodes: The number of files the user is currently using.
- Soft Limit: The maximum blocks/inodes a quota user may have on a partition. The role of a soft limit changes if grace periods are used. When this occurs, the user is only warned that their soft limit has been exceeded. When the grace period expires, the user is barred from using additional disk space or files. When set to zero, limits are disabled.
- Hard Limit: The maximum blocks/inodes a quota user may have on a partition when a grace period is set. Users may exceed a soft limit, but they can never exceed their hard limit.
Here user mp3user is limited to a maximum of 5MB of data storage on /dev/hda3 (/home):
Disk quotas for user mp3user (uid 503):
Filesystem blocks soft hard inodes soft hard /dev/hda3 24 5000 0 7 0 0
Testing
Linux checks the total amount of disk space a user uses each time a file is accessed and compares it against the values in the quota file. If the values are exceeded, depending on the configuration, then Linux prevents the creation of new files or the expansion of existing files to use more disk space.
Other Quota Topics
Creating disk quotas frequently isn't enough. You also have to manage the process by reviewing the quota needs of each user and adjusting them according to the policies of your company. You'll need to make Linux scan its hard disks periodically to check for exceeded quotas. This section describes the most common quota management activities.
Editing Grace Periods
The edquota -t command sets the grace period for each filesystem. Like the edquota -u command, it invokes the vi editor.
The grace period is a time limit before the soft limit is enforced for a quota-enabled file system. You can use time units of seconds, minutes, hours, days, weeks, and months. This is what you'll see with the command edquota -t.
[root@bigboy tmp]# edquota -t
Grace period before enforcing soft limits for users: Time units may be: days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period /dev/hda3 7days 7days
Note: There should be no spaces between the number and the unit of time measure. Therefore in this example, "7days" is correct and "7 days" is wrong.
Editing Group Quotas
Editing quotas on a per-group basis can be done similarly with the edquota -g command.
Getting Quota Reports
The repquota command lists quota usage limits of all users on the system. Here is an example.
[root@bigboy tmp]# repquota /home *** Report for user quotas on device /dev/hda3 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 52696 0 0 1015 0 0 ... ... ... mp3user -- 24 0 0 7 0 0 [root@bigboy tmp]#
Conclusion
Disk quotas are good to put in place for specific users whose disk usage activities need to be curtailed. It helps to not only limit the use of physical disk resources that could potentially be put to better use, but also reduces the likelihood of having fragmented disk structures that slow disk access due to the presence of too many files. User education must play a major role in your strategy too; users must be made aware of the challenges you face as a result of excessive disk usage. Of course, there comes a time when you are faced with no option but to expand the number of disks in your system. Chapter 27, "Expanding Disk Capacity", covers a variety of approaches to increasing your storage capacity.