Linux Learning-Disk quotas tool quota

Source: Internet
Author: User
Tags inode usage

Disk Quotas--linux as a multi-user operating system, in real life will occur in a common use of a disk, in order to ensure the effective use of a disk, the use of disk must be limited, so disk quotas (quota) is a very useful tool

Directory

    • Restrictions on the use of quota

    • Quota setting content (XFS)

    • Use of quota case (emphasis)

I. Restrictions on the use of quota

For the EXT series File system, the quota can only be designed for the entire file system , unable to disk quotas for a single directory, and in XFS 's file system you can use quota to directory Disk quotas, so be sure to check the file system before you make disk quotas.

The core must support quota, andCENTOS7 supports quota functionality by default.

Valid only for average users , because root has all the disk space.

If the SELinux feature is enabled, not all directories can be quota, and the default quota can only be set for/home.

Ii. setting content of quota (XFS)

Disk quotas for users, groups, individual directories (User,group,project), respectively

Limiting the amount of inode and block , since quota is managing the file system, the limitations on inode and block are also understandable

Soft/hard, which indicates the size of a specific limit, when the disk capacity reaches soft, the system warns you to lower the soft value, and when hard is reached, the system disables the addition of new files.

Grace Time (typically 7 days), when a user uses disk capacity to reach soft, the system will give Grace times, if more than this number of days, the soft value will become a hard value and prevent the user from adding new files to the disk

Third, the use of quota case

① scripting/app/bin/adduser.sh, creating User myquota1,myquota2,myquota3, myquota4,myquota5, and passwords are all CentOS. are located in the MYQUOTAGRP group. These five users have a shared directory/app/home/myquota, and only myquotagrp all members of this group have full permissions on the shared directory, others do not have any permissions.

1 #!/bin/bash 2 Groupadd myquotagrp 3 for num in {1..5} 4 do 5 useradd-d/app/home/myquota$num-g myquotagrp myqu  Ota$num 6 echo "CentOS" |passwd--stdin myquota$num 7 done 8 Mkdir/app/myquota 9 Chgrp Myquotagrp/app/myquota 10 chmod 2770/app/myquota

See the results below:


② file system detection and turn on file system support

Since Centos7 is an XFS file system by default and the kernel supports quota functions, it is tested with the Centos7/app directory,

For XFS file systems, the-o remount option for the Mount command does not take effect because the quota function is determined at the beginning of the mount, and can only be modified /etc/fstab The file is quota enabled, then uninstalled (Umount/app) and then re-mounted (Mount/app), the following changes are made:

There are three main categories set for quota :

· Usrquota Users

· Grpquota Group

        · Prjquota Single directory, but cannot exist with Grpquota

③ observation of quota management data

Let's look at this instruction first:Xfs_quota

Xfs_quota-x-C "command" [Mount Point]

-X Expert mode, follow-up can be followed by the-C option

- c followed by command

Command:print A simple list of file system information in the host

DF is the same as the original DF command, but is more accurate than the original DF display

The report must be followed by a load point that supports quota, listing quota project Settings

The report can be followed by-u-g-p-i-b-h and other options

back with-u-g-p value to display the corresponding information, rather than the entire user/group/project column,-I display inode usage,-H for people to read the unit (such as KB,MB, etc.)

State lists the quota status of the file system that supports the quota feature (User/group/project is turned on )

④ setting the size of a limit value

Set Myquota1,myquota2,myquota3,myquota4, Myquota5 soft/hardas 250m/300m limit, Grace time set to 14 days.

Xfs_quota-x-C "limit-u bsoft=250m bhard=300m myquota1"/appxfs_quota-x-C "limit-u bsoft=250m bhard=300m myquota2"/A Ppxfs_quota-x-C "limit-u bsoft=250m bhard=300m myquota3"/appxfs_quota-x-C "limit-u bsoft=250m bhard=300m myquota4" /appxfs_quota-x-C "limit-u bsoft=250m bhard=300m myquota5"/appxfs_quota-x-C "Timer-u-B 14days"/app

After setting the state:

Then cut to myquota1 user Experiment Quota results:

Create 310M files in the home directory, display the error, while viewing the home directory of the newly created file size is actually 300M

⑤ Restrictions on project (/app/myquota directory limit)

First step: Set the directory, project name (projects), Project ID

Where need to configure two related files /etc/projects,/etc/projid(the default does not have these two files, need to create, if the file name error after the will fail)

echo "11:/app/myquota" >/etc/projects #设置项目ID和目录的对应关系echo "myquotaproject:11" >/etc/projid # Set the correspondence between project name and project ID xfs_quota-x-C "Project-s Myquotaproject" #初始化项目名称

Step two: Set the specific limit value for the directory, setting/app/myquota to 450m/500m

Xfs_quota-x-C "limit-p bsoft=450m bhard=500m myquotaproject"/app





Linux Learning-disk quota tool quota

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.