How to use Quota

Source: Internet
Author: User

Question: ◇ how to use quota

Mailing station: BBS kapok station of South China University of Technology

Sender: "Chance" <chance@access.ttn.com.tw>, panel: Linux

======================================================== =========================================<

What is quota?

Quota allows you to specify disk storage limits in two ways: the number of index nodes (inodes) that the user can control and the number of disk blocks that the user can use.

The meaning behind quota is to force users to stay under their disk usage limit for most of the time and cancel their unlimited disk space usage on the system.

Quota in Linux

As far as I know, quota support has been integrated into the core since version 1.3.8x, and is also in the core of version 2.0. If your system does not support quota, I suggest you update it.

So far, quota can only operate on the ext2 file system.

In Linux, the core of quota 2.x can be obtained from this

Ftp://tsx-11.mit.edu/pub/linux/sources/system/v2.0/

Quota Software

Depending on your Linux distribution suite, quota software may have been installed on your system or not. The original code of quota can be obtained from here.

Ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linus/subsystems/quota/all.tar.gz.

----------------------------------------------------------------

Set quota on Linux-Part 1: Configuration

1. Configure your core

Reconfigure your core and Answer Y for this option to add quota support:

Quota support (config_quota) [N] y

2. Compile and install the quota Software

The original code of quota can be obtained from here.

Ftp://ftp.funet.fi/pub/Linux/PEOPLE/Linus/subsystems/quota/all.tar.gz

Although the quota software package I mentioned above has been transplanted to Linux and should be compiled on the core system of version 2.x, you may encounter some troubles, the C compiler constantly complains about some undefined mntopt. If this problem occurs, you need to copy its mntent. h file to/usr/include/metent. h to compile quota.

3. Modify the boot command draft of your system to check quota and enable quota during startup.

Here is an □example:

# Check quota and then turn quota on.

If [-x/usr/sbin/quotacheck]

Then

Echo "Checking quotas. This may take some time ."

/Usr/sbin/quotacheck-avug

Echo "Done ."

Fi

If [-x/usr/sbin/quotaon]

Then

Echo "turning on quota ."

/Usr/sbin/quotaon-avug

Fi

The constant rule is that you * always * need to open quota after the file system in your/etc/fstab *. Otherwise, quota will not work. I recommend that you enable quota at the bottom of your system's boot command draft, or, if you like, open it when your system command is just attached to the file system.

4. Modify/etc/fstab

The shard that has not enabled quota generally looks like:

/Dev/hda1/ext2 defaults 1 1

/Dev/hda2/usr ext2 defaults 1 1

To add quota to the file system, add "usrquota" to the fourth column containing "defaults ".

/Dev/hda1/ext2 defaults 1 1

/Dev/hda2/usr ext2 defaults, usrquota 1 1

5. Create the quota record "quota. User"

This quota record file, quota. user, should be owned by root, and root has read and write permissions, and no one else has. Check in as root. Enter the top layer of the shard where you want to enable quota, and create quota. user as follows:

Touch/partition/quota. user

Chmod 600/partition/quota. user

6. Restart

Restart the system to make your changes take effect. At the same time, note that you only need steps 4, 5 to enable other quota partitions,

And 6.

Set quota in Linux-Part 2: Specify the Quota for the user. This operation is executed using the edquota command. For example, the "edquota bob" command will bring you into vi (or the EDITOR specified in your $ EDITOR Environment Variable) this allows the user "bob" to edit the quota on each shard where quota is enabled.

Quotas for user bob:

/Dev/hda2: blocks in use: 2594, limits (soft = 5120, hard = 6400)

Inodes in use: 356, limits (soft = 1000, hard = 1500)

"Blocks in use" is the total number of blocks that the user has used in a partition (in kilobytes)

"Inodes in use" is the total number of files owned by the user in a partition.

In addition to edquota, there are three additional terms you should be familiar with: Soft restrictions, hard restrictions, and buffer periods.

Soft Limits

Generally, the soft limit indicates the total disk usage of the quota user in the partition. However, when the buffer is used together, its action is like a critical line. When the quota user exceeds the threshold, a warning is issued about his or her upcoming violation of the quota.

Hard limit

The hard limit only works when a buffer is set. It indicates the absolute limit on disk usage, and the quota user cannot exceed its hard limit.

Buffer period

Run the "edquota-t" command. During the buffer period, the time limit before the quota user is soft. The available time units are seconds, minutes, hours, days, weeks, and months. This is what you will see when using the "edquota-t" command:

Time units may be: days, hours, minutes, or seconds

Grace period before enforcing soft limits for users:

/Dev/hda2: block grace period: 0 days, file grace period: 0 days

Change the part 0 days to any period that you feel reasonable. I personally select 7 days

(OR 1 week ).

----------------------------------------------------------------

Other Quota commands

Quotacheck

Quotacheck is used to scan the disk usage of the file system and update the "quota. user" quota record to the latest status. I recommend that you periodically execute quotacheck at system startup or execute it every other time (for example, a week? ).

Repquota

Repquota generate the summary of the file system quota information. Here we have a repquota output □example:

# Repquota-

Block limits file limits

User used soft hard Grace used soft hard grace

Root -- 175419 0 0 14679 0 0

Bin -- 18000 0 0 735 0 0

Uucp -- 729 0 0 23 0 0

Man -- 57 0 0 10 0

User1 -- 13046 15360 19200 806 1500

User2 -- 2838 5120 6400 377 1000

Quotaon and Quotaoff

Quotaon is used to enable quota computing; quotaoff is used to disable it. In fact, the two are very similar. They are executed during system startup and shutdown.

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.