CentOS summary and practices on quota

Source: Internet
Author: User

CentOS summary and practices on quota

1. Theoretical Basis

1.1 concepts of Quota

Quota refers to the Quota, which is used to limit the space used by users, groups, and folders.

1.2 usage examples

-The web server controls the available space of the site.

-The mail server controls the user's available space.

-The file server controls the size of the user's available space.

1.3 restricted mode

-Control the available space size of each user based on the user (UID)

-Control the available space size of each group based on the group (GID)

-Control the available space of each directory based on directory (project) (xfs available project mode)

1.4 conditions of use

-Only file systems can be restricted in EXT format, and projects can be restricted in xfs format.

-The kernel must be pre-enabled for Quota support

-Quota is only valid for non-administrators.

-By default, Quota is only enabled for/home, And SELinux needs to be configured for others.

1.5 restricted configurable objects

-User, Group, and project)

-Capacity limit or file quantity limit (block/inode)

-Restricted values: soft (warning and extended time for exceeding the space usage) and hard (the user's right to use is denied if the space usage is exceeded)

-Grace time: the amount of space exceeds the soft limit and the processing time limit is not reached. (The soft value becomes hard)

2. Actual Operation

2.1 preparations before configuration

2.1.1 create a user group

groupaddgp1

2.1.2 add group members

useradd-ggp1user1echo"pwd1"|passwd--stdinuser1useradd-ggp1user2echo"pwd1"|passwd--stdinuser2

2.1.2 create a user directory and change all Groups

mkdir/home/gp1chgrpgp1/home/gp1chmod2770/home/gp1

2.1.2 check the file system type

df-hT/home

Shown as follows:

FilesystemTypeSizeUsedAvailUse%Mountedon/dev/mapper/centos-homexfs5.0G67M5.0G2%/home

2.2 enable the file system's quota Function

2.2.1 edit fstab

vim/etc/fstab

The modification content is as follows:

/dev/mapper/centos-home/homexfsdefaults,usrquota,grpquota00

Note:

-User (uquota/usrquota/quota)

-Group (gquota/kgquota)

-Directory (pquota/prjquota)

2.2.2 uninstall and re-mount

umount/homemount-a

2.2.3 check

mount|grephome

Shown as follows:

/dev/mapper/centos-homeon/hometypexfs(rw,relatime,seclabel,attr2,inode64,usrquota,grpquota)

2.3 check Quota Information

2.3.1 Command Format

xfs_quota-x-c"Sub-commands"[Mount point]Option:-X: EXPERT mode.-c can be used only when-x is used.-C: Sub-Command OptionsSub-command:Print: list the current system parameters.df: SimilardfThe options include-B (block)-I (inode)-h (plus a single bit) and so on.Report: ListquotaProject, including-ugr (user/group/project) And-biState: List currently supportedquotaFile System Information and Related startup items

2.3.2 query partitions that support Quota

xfs_quota-x-c"print"

2.3.3 query the usage of the Quota directory

xfs_quota-x-c"df-h"/hom

2.3.4 display the user's Quota restrictions

xfs_quota-x-c"report-ubih"/home

Note: The "-u" parameter is displayed for the project"

2.4 configuration restrictions

2.4.1 command format:

xfs_quota-x-c"limit[-ug]b[soft|hard]=Ni[soft|hard]=Nname"xfs_quota-x-c"timer[-ug][-bir]Ndays"Option:Limit: Restricted object, including user/group/projectbsoft/bhard: Block soft/hardLimit Valueisoft/ihard: Inode soft/hardLimit ValueName: user and group nameTimer: gracetime)

2.4.2 user and block size restrictions

xfs_quota-x-c"limit-ubsoft=250Mbhard=300Muser1"/homexfs_quota-x-c"limit-ubsoft=250Mbhard=300Muser2"/home

Check Configuration:

xfs_quota-x-c"report-ubih"/home

2.4.3 group and block size restrictions

xfs_quota-x-c"limit-gbsoft=950Mbhard=1Ggp1"/home

Check Configuration:

xfs_quota-x-c"report-gbih"/home

2.4.5 configure the grace period

xfs_quota-x-c"timer-ug-b14days"/home

Verify Configuration:

xfs_quota-x-c"state"/home

2.4.6 verify Quta

su-user1ddif=/dev/zeroof=123.imgbs=1Mcount=310ll-hexitxfs_quota-x-c"report-ubh"/home

2.5 project restrictions

2.5.1 modify fstab

vim/etc/fstab

2.5.2 Unmount and remount

umount/homemount-a

2.5.3 check canceled

xfs_quota-x-c"state"

2.5.4 create a project storage location

mkdir/home/proj01

2.5.5 specify the project identification number

echo"01:/home/proj01">>/etc/projects

2.5.6 specify the project name and associate it with the Project Identification Number

echo"proj01:01">>/etc/projid

2.5.7 initialize the project name

xfs_quota-x-c"project-sproj01"

Check Configuration:

xfs_quota-x-c"print"/homexfs_quota-x-c"report-pbih"/home

2.5.8 configure the limit based on the block size

xfs_quota-x-c"limit-pbsoft=450Mbhard=500Mproj01"/home

Check Configuration:

xfs_quota-x-c"report-pbih"/home

2.5.9 Verify Configuration

ddif=/dev/zeroof=/home/myquota/123.imgbs=1Mcount=510

2.6 Quota Management

2.6.1 temporarily disable the Quota restriction

xfs_quota-x-c"disable-up"/home

Check disabled:

xfs_quota-x-c"state"/home

Disable Verification:

ddif=/dev/zeroof=/home/user1/123.imgbs=1Mcount=520

Check the Quota status:

xfs_quota-x-c"report-pbh"/home

Clear test files:

rm-rf/home/user1/123.img

2.6.2 temporary start of Quota restrictions

xfs_quota-x-c"enable-up"/home

Check Start:

ddif=/dev/zeroof=/home/user1/123.imgbs=1Mcount=520

2.6.3 completely disable the Quota restriction

xfs_quota-x-c"off-up"/home

Close test:

xfs_quota-x-c"enable-up"/home

Close recovery:

umount/home;mount-a

2.6.4Delete the Quota limit (cannot be recovered)

xfs_quota-x-c"off-up"/homexfs_quota-x-c"remove-p"/home

Verify deletion:

xfs_quota-x-c"report-phb"/home

2.7 implement Quota using soft connections

1) enable the/home partition's Quota Function

Edit fstab

vim/etc/fstab

The modification content is as follows:

/dev/mapper/centos-home/homexfsdefaults,usrquota,grpquota00

2) create a soft connection to the Quota Partition

ln-s/home/mail/var/spool/mail

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

See documentation

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

Http://linux.vbird.org/linux_basic/0420quota.php

Http://www.centoscn.com/CentOS/config/2013/1103/2043.html

Http://www.jb51.net/ OS /RedHat/400503.html

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.