1. What is quota
Simply put, limit the amount of disk space users use.
Because Linux is a multi-user multitasking operating system, many people share disk space, in order to allocate disk space reasonably, so there is a quota appearance.
Use of 2.quota
Show disk usage and quotas
general Action object of 3.quota
(1) for WWW server
(2) for mail server
(3) for file server
Limitations of 4.quota
(1) Only for the entire file system
(2) Need kernel support
(3) Valid only for general users
Use of 5.quota
Test environment
RHEL6.6 (default kernel already supports quota functionality)
/DEV/SDB1 File System for testing
User Group Myquota
User Quota1,quota2
The operation is as follows
(1) Re-hang the/dev/sdb1 file system and add the Usrquota,grpquota parameter
[Email protected] ~]# Mount-o REMOUNT,USRQUOTA,GRPQUOTA/DEV/SDB1
After re-mounting, the/DEV/SDB1 partition supports the quota function.
[email protected] ~]# Mount | Grep/dev/sdb1
/DEV/SDB1 on/mnt/test type EXT4 (rw,Usrquota,grpquota)
(2) Adding user groups and users
[Email protected] ~]# Groupadd Myquota
[Email protected] ~]# useradd-g Myquota quota1
[Email protected] ~]# useradd-g Myquota quota2
(3) Generate quota configuration file
[Email protected] ~]# cd/mnt/test/
[Email protected] test]# Quotacheck-ug.
[[email protected] test]# ls
Aquota.group Aquota.user lost+found Generating Quota configuration file
(4) Start quota function
[Email protected] test]# QUOTAON/DEV/SDB1
To turn off the use Quotaoff command
(5) Modify the quota configuration file
The configuration file contents are as follows
Filesystem blocks soft hard inodes soft hard
/DEV/SDB1 0 0 0 0 0 0
The value that needs to be modified is Soft/hard, the unit is Kb,soft is the warning value, hard is the maximum value, when disk usage between Soft-hard, will issue a warning (default countdown 7 days), if the warning time, the disk usage is still between Soft-hard, The use of disk space is prohibited.
If you modify the Soft/hard of blocks to indicate the amount of disk space that the user can use (typically, disk usage is specified)
If you modify the Soft/hard value of Inodes, the number of files that the user can create is specified.
[Email protected] test]# edquota-u quota1-Modify configuration for quota1 users
Disk quotas for user quota1 (UID 500):
Filesystem blocks soft hard inodes soft hard
/DEV/SDB1 0 100000 200000 0 0 0
[Email protected] test]# edquota-u QUOTA2-Modify configuration for QUOTA2 users
Disk quotas for User quota2 (UID 501):
Filesystem blocks soft hard inodes soft hard
/DEV/SDB1 0 100000 200000 0 0 0
[Email protected] test]# edquota-g Myquota-Modify configuration for Myquota Group
Disk quotas for group Myquota (GID 500):
Filesystem blocks soft hard inodes soft hard
/DEV/SDB1 251200 100000 300000 3 0 0
This configuration means that the QUOTA1,QUOTA2 user uses up to 200M of disk space, warns and enters the countdown for more than 100M, while the Myquota group uses up to 300M of disk space.
That is, although quota1,quota2 have 200M of maximum disk space to use permissions, but they belong to the Myquota group, their total amount must not exceed 300M
Modify Permissions
[Email protected] test]# chmod 777.
[Email protected] test]# ll-d
Drwxrwxrwx. 3 root root 4096 August 23 09:36.
Switch quota1 user, test
[email protected] test]# su quota1
[[email protected] test]$ dd If=/dev/zero of=bigfile1 bs=1m count=150
sdb1:warning, user block quota exceeded. --Warning
Recorded 150+0 read-in
Recorded the writing of 150+0.
157286400 bytes (157 MB) Replicated, 1.02545 sec, 153 Mb/sec
Write a large file again
[[email protected] test]$ dd If=/dev/zero of=bigfile2 bs=1m count=150
Sdb1:write failed, user block limit reached.
DD: Writing "Bigfile2": the portion that exceeds the disk limit and exceeds 200M cannot be written to
Recorded 46+0 read-in
Recorded the writing of 45+0.
47513600 bytes (in megabytes) copied, 0.381467 sec. mb/s
Toggle Quota2 User
[email protected] test]# su quota2
[[email protected] test]$ ls
Aquota.group aquota.user bigfile1 bigfile2 lost+found
[[email protected] test]$ dd If=/dev/zero of=bigfile3 bs=1m Count 50
Recorded 50+0 read-in
Recorded the writing of 50+0.
52428800 bytes (.) Copied, 0.410838 sec, @ MB/s
Modify Warning Time
[Email protected] test]$ edquota-t
Grace period before enforcing soft limits for users:
Time units may be:days, hours, minutes, or seconds
Filesystem Block grace period Inode grace period
/DEV/SDB1 7days 7days
View Quota1 's Quota information
[Email protected] test]$ quota-u quota1
Disk quotas for user quota1 (UID 500):
Filesystem blocks Quota limit grace files quota limit Grace
/DEV/SDB1 200000* 100000 200000 6days 2 0 0--it's a warning countdown.
Querying QUOTA2 's Quota information
[[email protected] test]# quota-u quota2
Disk quotas for user quota2 (UID 501):
filesystem blocks quota limit grace files & nbsp quota limit Grace
/dev/sdb1 51200 100000 200000 1 0 0
Querying quota information for Myquota groups
[Email protected] test]# quota-g Myquota
Disk quotas for group Myquota (GID 500):
Filesystem blocks Quota limit grace files quota limit Grace
/DEV/SDB1 251200* 100000 300000 6days 3 0 0
Summarize:
Quotacheck [-GUBCFINVDMMR] [-F Quota-format]-a | FileSystem
-A check all the file systems that are hanging in the/etc/mtab
-U only checks the user's quota
-G checks only the user group's quota
Quota
Query the current user's quota information without using any parameters
-u username querying a user's quota information
-G groupname query quota information for a user group
Edquota
-u username editing a user's quota configuration
-G groupname edit quota configuration for a user group
-T Edit warning time configuration
There is also a comprehensive query command that is
Repquota
-A reports all file systems that support quota
-U reports quota information for user
-G package Quota information for group
Typically three parameters are used together
[Email protected] test]# Repquota-aug
Report for user quotas on DEVICE/DEV/SDB1
Block Grace Time:7days; Inode Grace Time:7days
Block Limits File Limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
Root--20 0 0 2 0 0
Quota1 +-200000 100000 200000 6days 2 0 0
QUOTA2--51200 0 0 1 0 0
Report for group quotas on DEVICE/DEV/SDB1
Block Grace Time:7days; Inode Grace Time:7days
Block Limits File Limits
Group used soft hard grace used soft hard grace
----------------------------------------------------------------------
Root--20 0 0 2 0 0
Myquota +-251200 100000 300000 7days 3 0 0
Linux disk quotas (quota)