Quota disk quota, quota

Source: Internet
Author: User

Quota disk quota, quota

I. Installation

Yum install quota

Ii. Configuration

1. Create a New partition sdb1 and format it

2,

[Root @ server05/] # mkdir/common

[Root @ server05/] # mount/dev/sdb1/common/

[Root @ server05/] # mount

/Dev/sdb1 on/common type ext4 (rw)

Only rw is found.

[Root @ server05/] # mount-o remount, usrquota/dev/sdb1

/Dev/sdb1 on/common type ext4 (rw, usrquota)

Userquota is added to the property.

[Root @ server05/] # mount-o remount, usrquota, kgquota/dev/sdb1

[Root @ server05/] # mount

/Dev/sdb1 on/common type ext4 (rw, usrquota, usrquota, kgquota)

Added the attributes of the target instance.

[Root @ server05/] # umount/dev/sdb1

Step by step:

[Root @ server05/] # mount-o usrquota, maid/dev/sdb1/common/

 

!!! Disable Firewall

[Root @ server05/] # quotacheck/common/

 

Configure a user quota

[Root @ server05 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

 

[Root @ server05 common] # quotaon/common

[Root @ server05 common] # quotacheck/common

[Root @ server05 common] # quotaon/common/

 

[Root @ server05/] # chmod o + w common/

[Root @ server05 common] # su-redhat

[Redhat @ server05 common] $ touch abc

 

You can see that the redhat user has the permission to create a file.

 

 

Now you can verify

[Redhat @ server05 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

[Redhat @ server05 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.

[Root @ server05 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

[Root @ server05 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

[Root @ server05 common] # su-redhat

[Redhat @ server05 ~] $ 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

 

[Root @ server05 redhat] # mount-o remount, usrquota, kgquota/common/

/Dev/sdb1 on/common type ext4 (rw, usrquota, kgquota)

 

[Root @ server05 redhat] # quotaoff/common

[Root @ server05 redhat] # cd/common/

[Root @ server05 common] # rm-rf *

 

[Root @ server05 common] # quotacheck/common/

[Root @ server05 common] # ls

Aquota. user

[Root @ server05 common] # quotacheck-g/common/

[Root @ server05 common] # ls

Aquota. group aquota. user

 

[Root @ server05 common] # edquota-g redhat

Edit redhat group quota


Why does the quota disk quota set in Linux not take effect?

If it is for root, it will not take effect, and you are advised to change the configuration file! Do not use commands! Another possibility is that the user has already exceeded the limit, and the disk quota does not take effect now! Take a good look!
 
Disk Quota command?

I have never done the disk quota for a long time. Use the quota command.
First, the usrquota attribute must be included in the partition mounting attribute. The usrquota attribute is for the user quota, and a groupquota attribute is for the group quota.
Then, use quota-a to scan and/etc/fstab with the partition with the previous attribute. Then the quota database is generated.
Then, set the user's quota: edquota-u username to set the quota for the specified user.
Finally, the disk quota is enabled for quota on.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.