|
Linux Quota Tutorial - Quota Configuration |
|
|
|
|
Written by Tom Hirt
|
|
Tuesday, 26 May 2009 13:52 |
|
Page 2 of 3
Quota Configuration
Now that we have some background on the Linux Quota system, we are now ready to begin the quota configuration. Let's get started!
- Enable quota support by appending usrquota,grpquota to each of the file systems you wish to enforce a quota on within the /etc/fstab file. In the below example, we have enabled quota support on / and /home.
| /dev/VolGroup00/LogVol04 |
/
|
ext3 |
defaults,usrquota,grpquota |
1 |
1 |
| LABEL=/boot |
/boot |
ext3 |
defaults |
1 |
2 |
| devpts |
/dev/pts |
devpts |
gid=5,mode=620 |
0 |
0 |
| tmpfs |
/dev/shm |
tmpfs |
defaults |
0 |
0 |
| /dev/VolGroup00/LogVol00 |
/home
|
ext3 |
defaults,usrquota,grpquota |
1 |
2
|
| proc |
/proc |
proc |
defaults |
0 |
0 |
| sysfs |
/sys |
sysfs |
defaults |
0 |
0 |
| /dev/VolGroup00/LogVol02 |
/tmp |
ext3 |
defaults |
1 |
2 |
| /dev/VolGroup00/LogVol03 |
/var |
ext3 |
defaults |
1 |
2 |
| /dev/VolGroup00/LogVol01 |
swap |
swap |
defaults |
0 |
0 |
|
Note: The contents of your /etc/fstab file may differ. We have highlighted the additions which were added to our /etc/fstab file.
- Remount the file system(s) to enable quota support
[root@Linux01 ~]# mount -o remount / [root@Linux01 ~]# mount -o remount /home
|
- Initalize the new quota database. After running the quotacheck -cug <FILE SYSTEM> command, you will find a aquota.useraquota.group and file located in the root of each file system. These files describe the quota policy to be enforced on the file system(s) for each user and/or group and their associated grace time.
Initializing the database:
[root@Linux01 /]# quotacheck -cug / [root@Linux01 /]# quotacheck -cug /home/
|
Verify the creation of the quota database files:
[root@Linux01 /]# ls -al /aquota* -rw------- 1 root root 6144 May 26 17:15 /aquota.group -rw------- 1 root root 6144 May 26 17:15 /aquota.user [root@Linux01 /]# ls -al /home/aquota* -rw------- 1 root root 7168 May 26 17:16 /home/aquota.group -rw------- 1 root root 7168 May 26 17:16 /home/aquota.user
|
- Schedule a task in cron to scan the system for quota-checking. You should be aware that scanning the system can be I/O intensive. Your system may have different needs than the examples given below, but be aware and expect heavy I/O during the times the scans run (scheduling a scan in the middle of the day at peak production usage may not be the best idea.)
| #MIN (0-59) |
HOUR (0-23)
|
DoM (1-31) |
MONTH (1-12) |
DoW (0-7) |
CMD |
| 0 |
1 |
* |
* |
0 |
quotacheck -vug / |
| 20 |
1 |
* |
* |
* |
quotacheck -vug /home |
|
Note: In the above example, we have schedule a weekly scan of / for 1:00AM and a daily scan of /home scheduled for 1:20AM
- Enable quota support on the file system(s). The easiest way to enable quota support is to simply reboot the system. The systems init scripts should automatically enable quota support assuming its supported by the kernel. Optionally, you can use the quotaon command to enable quota support on a file system without having to reboot the system.
Note: For some distributions, you may have to enable quota support manually or create an init script to do so for you; consult you distributions documentation for details.
Enable quota support without a system reboot:
[root@Linux01 /]# quotaon /home [root@Linux01 /]# quotaon /
|
Verify quota support is enabled on a file system
[root@Linux01 /]# quotaon -p /home group quota on /home (/dev/mapper/VolGroup00-LogVol00) is on user quota on /home (/dev/mapper/VolGroup00-LogVol00) is on [root@Linux01 /]# quotaon -p / group quota on / (/dev/mapper/VolGroup00-LogVol04) is on user quota on / (/dev/mapper/VolGroup00-LogVol04) is on [root@Linux01 /]# |
Note: Quota support has been enabled on the /home and / file systems
|
|
Last Updated on Tuesday, 02 June 2009 10:07 |