I. Installation
Yum install quota
Ii. Configuration
1. Create a New partition sdb1 and format it
2,
[[Email protected]/] # mkdir/common
[[Email protected]/] # Mount/dev/sdb1/common/
[[Email protected]/] # Mount
/Dev/sdb1 on/common type ext4 (RW)
Only RW is found.
[[Email protected]/] # Mount-O remount, usrquota/dev/sdb1
/Dev/sdb1 on/common type ext4 (RW, usrquota)
Userquota is added to the property.
[[Email protected]/] # Mount-O remount, usrquota, kgquota/dev/sdb1
[[Email protected]/] # Mount
/Dev/sdb1 on/common type ext4 (RW, usrquota, usrquota, kgquota)
Added the attributes of the target instance.
[[Email protected]/] # umount/dev/sdb1
Step by step:
[[Email protected]/] # Mount-O usrquota, maid/dev/sdb1/common/
!!! Disable Firewall
[[Email protected]/] # quotacheck/common/
Configure a user quota
[[Email protected] common] # edquota-u RedHat
Disk quotas for user RedHat (UID 500 ):
Filesystem blocks soft hard inodes soft hard
/Dev/sdb1 0 204800 409600 0 0 0
Soft limit: 200 m hard limit: 400 m
[[Email protected] common] # quotaon/common
[[Email protected] common] # quotacheck/common
[[Email protected] common] # quotaon/common/
[[Email protected]/] # chmod o + W common/
[[Email protected] common] # Su-RedHat
[[Email protected] common] $ touch ABC
You can see that the RedHat user has the permission to create a file.
Now you can verify
[[Email protected] common] $ dd If =/dev/Zero of = redhat_file BS = 1 m COUNT = 500
Sdb1: warning, user block quota exceeded.
Sdb1: Write failed, user block limit reached.
DD: Writing 'redhat _ file': Disk Quota exceeded
401 + 0 records in
400 + 0 records out
419430400 bytes (419 MB) Copied, 17.6664 S, 23.7 MB/S
[[Email protected] common] $
Sdb1: warning, user block quota exceeded. Warning for Soft Limits
Sdb1: Write failed, user block limit reached
The size is 419 MB.
You can also restrict your inodes.
[[Email protected] common] # edquota-u RedHat
Disk quotas for user RedHat (UID 500 ):
Filesystem blocks soft hard inodes soft hard
/Dev/sdb1 409600 204800 409600 2 200 1000
Set inodes soft limit to 200 hard limit to 1000
Use quota-U for viewing
[[Email protected] common] # quota-u RedHat
Disk quotas for user RedHat (UID 500 ):
Filesystem blocks quota limit Grace files quota limit grace
/Dev/sdb1 409600*204800 409600 7 days 2 200 1000
Log in as RedHat to view
[[Email protected] common] # Su-RedHat
[[Email protected] ~] $ Quota-s (-S for easy viewing)
Disk quotas for user RedHat (UID 500 ):
Filesystem blocks quota limit Grace files quota limit grace
/Dev/sdb1 409600*204800 409600 6 days 2 200 100
[[Email protected] RedHat] # Mount-O remount, usrquota, kgquota/common/
/Dev/sdb1 on/common type ext4 (RW, usrquota, kgquota)
[[Email protected] RedHat] # quotaoff/common
[[Email protected] RedHat] # cd/common/
[[Email protected] common] # rm-RF *
[[Email protected] common] # quotacheck/common/
[[Email protected] common] # ls
Aquota. User
[[Email protected] common] # quotacheck-g/common/
[[Email protected] common] # ls
Aquota. Group aquota. User
[[Email protected] common] # edquota-G RedHat
Edit RedHat group quota
Quota Disk Quota