First do:
yum install quota
Also you have to edit the edit the /etc/fstab and add:
usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0
If you do not need to set quotas for groups then omit the grpjquota=aquota.group, then in my fstab I have this:
UUID=b4a0be80-3a47-4609-af72-a30b7102593b / ext4 defaults 1 1 UUID=8f7f1ed5-4726-471f-a48e-76088180c099 /boot ext4 defaults 1 2 UUID=11315782-76c7-4380-b968-0bcef2f4b832 /home ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2 UUID=4dcacd31-c789-4406-8a71-fe1579ac5f4f swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults,nosuid,noexec,rw 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /var/tempFS /tmp ext4 loop,nosuid,noexec,rw 0 0
To create the quota files (aquota.user and aquota.group) on the file system, use the -c option of the quotacheck command. For example, if user and group quotas are enabled for the /home file system, create the files in the /home directory:
quotacheck -cug /home
The -c option specifies that the quota files should be created for each file system with quotas enabled, the -u option specifies to check for user quotas, and the -g option specifies to check for group quotas.
If neither the -u or -g options are specified, only the user quota file is created. If only -g is specified, only the group quota file is created.
After the files are created, run the following command to generate the table of current disk usage per file system with quotas enabled:
quotacheck -avugm
The options used are as follows:
- a — Check all quota-enabled, locally-mounted file systems
- v — Display verbose status information as the quota check proceeds
- u — Check user disk quota information
- g — Check group disk quota information
After quotacheck has finished running, the quota files corresponding to the enabled quotas (user and/or group) are populated with data for each quota-enabled locally-mounted file system such as /home
quotaon -avug
if you need to turn the quotas off then do:
quotaoff /home
or the equivalent
quotaon -f /home
The quota system is ready to go, now we have to set the quotas for every user:
edquota -u username
And we get:
Disk quotas for user username (uid 501):
Filesystem blocks soft hard inodes soft hard /dev/mapper/vg_aguila-lv_root 36 0 0 10 0 0
The system automatically uses the default editor.
If we want to set 5MB of quota for username then we edit the file to:
Disk quotas for user username (uid 501):
Filesystem blocks soft hard inodes soft hard /dev/mapper/vg_aguila-lv_root 36 5000 0 10 0 0
Gestão
Basics
Use this command to check for quotas on a specific partition:
# repquota /home
Use this command to check for all quotas that apply to a user:
# quota -u $USER
for groups;
# quota -g $GROUP
Copying quota settings
To copy quota from one user or group to the other, use this command:
# edquota -p user1 user2
User1 is the user you copy from, user2 is the user you copy quota to. Of course you can replace user with group, when necessary.
Multiple users
The idea is to make a temporary user acount, modify the quota settings for that user, and then copy the generated quota files for all users to use. After setting quota settings for quotauser, copy the settings:
# edquota -p quotauser `awk -F: '$3 > 999 {print $1}' /etc/passwd`
This applies the settings to users with a UID equal to or greater than 1000.
Other commands
There are several useful commands:
repquota -a # Shows the status on disk usage warnquota # Can be used to warn the users about their quota setquota # Non-interactive quota setting--useful for scripting
Lasty, quotastats is used to give thorough information about the quota system:
$ quotastats
Number of dquot lookups: 101289 Number of dquot drops: 101271 Number of still active inodes with quota : 18 Number of dquot reads: 93 Number of dquot writes: 2077 Number of quotafile syncs: 134518740 Number of dquot cache hits: 7391 Number of allocated dquots: 90 Number of free dquots: 2036 Number of in use dquot entries (user/group): -1946
Fonte:
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-disk-quotas.html
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-disk-quotas-managing.html
https://wiki.archlinux.org/index.php/Disk_Quota#Journaled_quota