Linux 用户 quote 配置 说明
?
一. Linux 配額(Quota)說明
?
在 Linux 系統中,由于是多人多任務的環境,所以會有多人共同使用一個硬盤空間的情況發生,為了合理使用這些空間,管理員需要控制用戶對磁盤空間的使用,這個就是Linux 下的配額管理。
配額管理是對某個磁盤分區進行限制。這里的限制包括2個方面:
1.單個用戶對某個目錄下空間大小的限制。
2.單個用戶對某個目錄下文件個數的限制。
?
1.1 Quota 常用在如下幾種情況
1)??針對 WWW server ,例如:每個人的網頁空間的容量限制。
2)??針對 mail server,例如:每個人的郵件空間限制。
3)??針對 file server,例如:每個人最大的可用網絡硬盤空間。
?
1.2 Quota 的2個注意事項
(1)僅針對整個 partition:
quota針對『整個 partition』進行限制, 例如:如果/dev/hda5 是掛載在 /dave 目錄下,那么在 /dave 目錄下的所有目錄都會受到限制。
?
(2)只對一般身份使用者有效:
不是所有在 Linux 上面的賬號都可以設定 quota,例如 root 就不能設定quota 。
?
?
1.3 Quota 的三種限制類型
(1)soft limit:
這是最低限制容量的意思,用戶在寬限期間之內,他的容量可以超過 soft ,但必需要寬限時間之內將磁盤容量降低到 soft 的容量限制之下。
?
(2)hard limit:
這是『絕對不能超過』的容量。通常hard limit 會比 soft limit 為高,例如網絡驅動器空間為 30 MB ,那么 hard limit 就設定為 30MB ,但是為了讓使用者有一定的警戒心,所以當使用空間超過 25 MB 時,例如使用者使用了 27 MB 的空間時,那么系統就會警告用戶, 讓使用者可以在『寬限時間內』將他的檔案量降低至 25 MB ( 亦即是 soft limit )之內。也就是說, soft 到 hard 之間的容量其實就是寬限的容量,可以達到針對使用者的『警示』作用。
?
(3)寬限時間:
寬限時間就是當使用者使用的空間超過了 soft limit ,卻還沒有到達 hard limit 時,那么在這個『寬限時間』之內,就必需要請用戶將使用的磁盤容量降低到 soft limit 之下。而當用戶將磁盤容量使用情況超過 soft limit 時,『寬限時間』就會自動被啟動,而在用戶將容量降低到 softlimit 之下,那么寬限時間就會自動的取消。
?
1.4 Quota 的安裝包
??? Quota也需要安裝,安裝包如下:
?
[root@rhce /]# rpm -q quota
quota-3.17-16.el6.x86_64
[root@rhce /]#
?
1.5 Quota 相關的命令
?
與Quota 相關的幾個命令如下。
?
1.5.1 啟用quota:quotaon
[root@rhce /]# quotaon
Bad number of arguments.
quotaon: Usage:
???????quotaon [-guvp] [-F quotaformat] [-x state] -a
???????quotaon [-guvp] [-F quotaformat] [-x state] filesys ...
?
-a, --all?????????????? ?turn quotas on for all filesystems
-f, --off??????????????? turn quotas off
-u, --user?????????????? operate on user quotas
-g, --group????????????? operate on group quotas
-p, --print-state??????? print whether quotas are on or off
-x, --xfs-command=cmd ???perform XFS quota command
-F, --format=formatname? operate on specific quota format
-v, --verbose??????????? print more messages
-h, --help?????????????? display this help text and exit
-V, --version??????????? display version information andexit
[root@rhce /]#
?
?
1.5.2 關閉quota:quotaoff
[root@rhce /]# quotaoff
Bad number of arguments.
quotaoff: Usage:
???????quotaoff [-guvp] [-F quotaformat] [-x state] -a
???????quotaoff [-guvp] [-F quotaformat] [-x state] filesys ...
?
-a, --all??????????????? turn quotas off for allfilesystems
-f, --off??????????????? turn quotas off
-u, --user?????????????? operate on user quotas
-g, --group????????????? operate on group quotas
-p, --print-state??????? print whether quotas are on or off
-x, --xfs-command=cmd??? perform XFS quota command
-F, --format=formatname? operate on specific quota format
-v, --verbose??????????? print more messages
-h, --help?????????????? display this help text and exit
-V, --version??????????? display version information andexit
?
1.5.3 配額發送警告:warnquota
[root@rhce /]# warnquota -h
warnquota: Usage:
?warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile][-a adminsfile]
?
-u, --user????????????????????? warn users
-g, --group???????????????????? warn groups
-s, --human-readable??????????? send information in more humanfriendly units
-i, --no-autofs???????????????? avoid autofs mountpoints
-d, --no-details??????????????? do not send quota informationitself
-F, --format=formatname???????? use quotafiles of specific format
-c, --config=config-file??????? non-default config file
-q, --quota-tab=quotatab-file?? non-default quotatab
-a, --admins-file=admins-file?? non-default admins file
-h, --help????????????????????? display this help messageand exit
-v, --version?????????????????? display version informationand exit
?
Bugs to jack@suse.cz
[root@rhce /]#
?
1.5.4 編輯配額屬性:edquota
[root@rhce /]# edquota
edquota: Usage:
???????edquota [-rm] [-u] [-F formatname] [-p username] [-f filesystem]username ...
???? ???edquota [-rm] -g [-F formatname] [-pgroupname] [-f filesystem] groupname ...
???????edquota [-rm] [-u|g] [-F formatname] [-f filesystem] -t
???????edquota [-rm] [-u|g] [-F formatname] [-f filesystem] -Tusername|groupname ...
?
-u, --user???????????? ???????edit user data
-g, --group?????????????????? edit group data
-r, --remote????????????????? edit remote quota (via RPC)
-m, --no-mixed-pathnames????? trim leading slashes from NFSv4mountpoints
-F, --format=formatname?????? edit quotas of a specific format
-p, --prototype=name????????? copy data from a prototype user/group
???--always-resolve????????? alwaystry to resolve name, even if it is
????????????????????????????? composed only ofdigits
-f, --filesystem=filesystem?? edit data only on a specific filesystem
-t, --edit-period???????????? edit grace period
-T, --edit-times????????????? edit grace time of a user/group
-h, --help??????????????????? display this help text andexit
-V, --version???????????????? display version informationand exit
?
Bugs to: jack@suse.cz
[root@rhce /]#
?
1.5.5 顯示配額信息:repquota
[root@rhce /]# repquota -h
repquota: Utility for reporting quotas.
Usage:
repquota [-vugsi] [-c|C] [-t|n] [-Fquotaformat] (-a | mntpoint)
?
-v, --verbose?????????????? display also users/groups withoutany usage
-u, --user????????????????? display information aboutusers
-g, --group???????????????? display information aboutgroups
-s, --human-readable??????? show numbers in human friendly units(MB, GB, ...)
-t, --truncate-names??????? truncate names to 8 characters
-p, --raw-grace???????????? print grace time in seconds sinceepoch
-n, --no-names????????????? do not translate uid/gid to name
-i, --no-autofs???????????? avoid autofs mountpoints
-c, --batch-translation???? translate big number of ids at once
-C, --no-batch-translation? translate ids one by one
-F, --format=formatname???? report information for specific format
-h, --help????????????????? display this help message andexit
-V, --version?????????????? display version information andexit
?
Bugs to jack@suse.cz
[root@rhce /]#
?
1.5.6 檢查并修復quota 配置文件:quotacheck
#quotacheck –cvug/tmp
?
[root@rhce ~]# quotacheck -h
Utility for checking and repairing quotafiles.
quotacheck [-gucbfinvdmMR] [-F<quota-format>] filesystem|-a
?
-u, --user??????????????? check user files
-g, --group?????????????? check group files
-c, --create-files??????? create new quota files
-b, --backup????????????? create backups of old quota files
-f, --force?????????????? force check even if quotas areenabled
-i, --interactive???????? interactive mode
-n, --use-first-dquot???? use the first copy of duplicated structure
-v, --verbose???????????? print more information
-d, --debug?????????????? print even more messages
-m, --no-remount????????? do not remount filesystem read-only
-M, --try-remount???????? try remounting filesystem read-only,
????????????????????????? continue even if itfails
-R, --exclude-root??????? exclude root when checking allfilesystems
-F, --format=formatname?? check quota files of specific format
-a, --all???????????????? check all filesystems
-h, --help??????????????? display this message and exit
-V, --version???????????? display version information andexit
?
Bugs to jack@suse.cz
[root@rhce ~]#
?
[root@rhce ~]#? quotacheck -cvug /dave
quotacheck: Your kernel probably supportsjournaled quota but you are not using it. Consider switching to journaled quotato avoid running quotacheck after an unclean shutdown.
quotacheck: Scanning /dev/sdc1 [/dave] done
quotacheck: Cannot stat old user quotafile: No such file or directory
quotacheck: Cannot stat old group quotafile: No such file or directory
quotacheck: Cannot stat old user quotafile: No such file or directory
quotacheck: Cannot stat old group quota file:No such file or directory
quotacheck: Checked 3 directories and 2files
quotacheck: Old file not found.
?
1.5.7 直接設置配額:setquota
[root@rhce ~]# setquota -h
setquota: Usage:
?setquota [-u|-g] [-rm] [-F quotaformat] <user|group>
???????<block-softlimit> <block-hardlimit> <inode-softlimit><inode-hardlimit> -a|<filesystem>...
?setquota [-u|-g] [-rm] [-F quotaformat] <-p protouser|protogroup><user|group> -a|<filesystem>...
?setquota [-u|-g] [-rm] [-F quotaformat] -b [-c] -a|<filesystem>...
?setquota [-u|-g] [-F quotaformat] -t <blockgrace><inodegrace> -a|<filesystem>...
?setquota [-u|-g] [-F quotaformat] <user|group> -T<blockgrace> <inodegrace> -a|<filesystem>...
?
-u, --user???????????????? set limits for user
-g, --group??????????????? set limits for group
-a, --all????????????????? set limits for allfilesystems
???--always-resolve?????? always tryto resolve name, even if is
?????????????????????????? composed only ofdigits
-F, --format=formatname??? operate on specific quota format
-p, --prototype=protoname? copy limits from user/group
-b, --batch??????????????? read limits from standard input
-c, --continue-batch?????? continue in input processing in case ofan error
-r, --remote?????????????? set remote quota (via RPC)
-m, --no-mixed-pathnames????? trim leading slashes from NFSv4mountpoints
-t, --edit-period????????? edit grace period
-T, --edit-times?????????? edit grace times for user/group
-h, --help???????????????? display this help text andexit
-V, --version????????????? display version information andexit
?
Bugs to: jack@suse.cz
[root@rhce ~]#
?
二. 配額使用示例
?
2.1 創建分區并mount到目錄
?
[root@rhce /]# fdisk /dev/sdc
Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with diskidentifier 0x1e051117.
Changes will remain in memory only, untilyou decide to write them.
After that, of course, the previous contentwon't be recoverable.
?
Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)
?
WARNING: DOS-compatible mode is deprecated.It's strongly recommended to
????????switch off the mode (command 'c') and change display units to
????????sectors (command 'u').
?
Command (m for help): n
Command action
??e?? extended
??p?? primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G}(1-652, default 652):
Using default value 652
?
Command (m for help): w
The partition table has been altered!
?
Calling ioctl() to re-read partition table.
Syncing disks.
?
[root@rhce /]# fdisk -l
?
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk identifier: 0x1e051117
?
??Device Boot????? Start???????? End????? Blocks??Id? System
/dev/sdc1?????????????? 1???????? 652????5237158+? 83? Linux
?
[root@rhce /]# mkfs -t ext3 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1309289 blocks
65464 blocks (5.00%) reserved for the superuser
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments pergroup
8192 inodes per group
Superblock backups stored on blocks:
???????32768, 98304, 163840, 229376, 294912, 819200, 884736
?
Writing inode tables: done?????????????????????? ?????
Creating journal (32768 blocks): done
Writing superblocks and filesystemaccounting information: done
?
This filesystem will be automaticallychecked every 30 mounts or
180 days, whichever comes first.? Use tune2fs -c or -i to override.
[root@rhce /]#
[root@rhce /]# mount/dev/sdc1 /dave
[root@rhce /]# vim /etc/fstab
/dev/sdc1???????? /dave?????????? ext3????????????????????? defaults??????? 0 0
?
我們這里將/dev/sdc1 映射到了目錄/dave.
?
2.2 創建2個測試用戶
?
[root@rhce /]# groupadd grp01
[root@rhce /]# groupadd grp02
[root@rhce /]# cat /etc/group|grep grp0*
grp01:x:503:
grp02:x:504:
[root@rhce /]#
?
[root@rhce /]# useradd dave01 -g grp01
[root@rhce /]# useradd dave02 -g grp02
?
[root@rhce /]# passwd dave01
Changing password for user dave01.
New password:
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updatedsuccessfully.
[root@rhce /]# passwd dave02
Changing password for user dave02.
New password:
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updatedsuccessfully.
[root@rhce /]#
?
2.3 修改分區表啟用配額限制
?
[root@rhce ~]# cat /etc/fstab????????????????????????????????????????????????????????????????
??????????????????????????????????????????? ??????????????????????????????????????????????????
tmpfs?????????????????? /dev/shm??????????????? tmpfs?? defaults??????? 0 0??????????????????
devpts????????????????? /dev/pts??????????????? devpts? gid=5,mode=620? 0 0??????????????????
sysfs????????? ?????????/sys??????????????????? sysfs?? defaults??????? 0 0??????????????????
proc??????????????????? /proc?????????????????? proc??? defaults??????? 0 0??????????????????
/dev/sdc1?????????????? /dave?????????????????? ext3??? defaults,usrquota,grpquot??????? 0 0
[root@rhce ~]#???????????????????????????????????????????????????????????????????????????????
?
?
/etc/fstab 文件的第四個字段是裝載文件系統是使用的選項:
(1)實現基于用戶的磁盤配額,就加入usrquota關鍵字,
(2)實現基于組的磁盤配額,就加入grpqouta關鍵字,如果兩者都需要,就全寫入,中間可以用逗號分隔。
?
注意:請特別注意這里的拼寫,是usrquota和grpquota,不要寫成userquota和groupquota。
?
?
2.4 重新Remount 分區
?
[root@rhce ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs(rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc typebinfmt_misc (rw)
none on /sys/kernel/config type configfs(rw)
sunrpc on /var/lib/nfs/rpc_pipefs typerpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs typefuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sdc1 on /dave typeext3 (rw)
?
分區是我們之前mount的,我們后來修改了mount的選項,增加了用戶和組的配額,所以這里我們重新mount一次,使我們的修改生效。
?
[root@rhce ~]# mount -oremount /dave
[root@rhce ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts(rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs(rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc typebinfmt_misc (rw)
none on /sys/kernel/config type configfs(rw)
sunrpc on /var/lib/nfs/rpc_pipefs typerpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs typefuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sdc1 on /dave typeext3 (rw,usrquota,grpquota)
[root@rhce ~]#
?
2.5 啟動并配置文件大小配額限制
?
--檢查配額文件
[root@rhce ~]# quotacheck/dave
quotacheck: Cannot create new quotafile/dave/aquota.user.new: Permission denied
quotacheck: Cannot initialize IO on newquotafile: Permission denied
?
這里關閉SELinux即可:
[root@rhce ~]# getenforce
Enforcing
[root@rhce ~]# setenforce 0
[root@rhce ~]# getenforce
Permissive
[root@rhce ~]#
?
--啟動配額限制
[root@rhce ~]# quotaon -vug /dave
/dev/sdc1 [/dave]: group quotas turned on
/dev/sdc1 [/dave]: user quotas turned on
[root@rhce ~]#
?
--開啟之后,會在/dave的目錄下自動創建配額的管理文件:aquota.group和aquota.user
[root@rhce dave]# pwd
/dave
[root@rhce dave]# ll
total 32
-rw-------. 1 root root? 6144 Jun 22 09:28 aquota.group
-rw-------. 1 root root? 6144 Jun 22 09:28 aquota.user
drwx------. 2 root root 16384 Jun 22 05:00lost+found
[root@rhce dave]#
?
?
這個文件我們不能直接編輯,我們需要使用edquota命令來進行編輯。
?
[root@rhce dave]# edquota -u dave01
Disk quotas for user dave01 (uid 503):
?Filesystem??????????????????blocks???? ??soft?????? hard ????inodes????soft???? hard
?/dev/sdc1????????????????????????0????? 10240????? 20480 ?????????0??????? 0???????0
?
這里的限制分三種:
1.blocks:按block的數量
2.soft:軟限制,單位為字節。
3.hard: 硬限制,單位為字節。
?
上例中,soft限制約為10MB,hard限制約為20MB,當用戶dave01使用空間超過10MB時,系統會進行提示,但可以繼續使用空間,而當用戶dave01使用空間達到20MB時,就會限制用戶dave01繼續使用/dave空間。
?
?
--查看報告:
[root@rhce dave]# repquota /dave
*** Report for user quotas on device/dev/sdc1
Block grace time: 7days;Inode grace time: 7days
??????????????????????? Block limits??????????????? File limits
User??????????? used??? soft???hard? grace??? used?soft? hard? grace
----------------------------------------------------------------------
root?????--? 141436?????? 0??????0????????????? 4???? 0????0??????
?
--這里只有root用戶的信息,因為其他用戶還沒有創建文件,一旦創建文件,就會限制了。
?
?
[root@rhce dave]#
?
--用dave01用戶創建文件進行配額限制的測試
?
--創建5M的文件:成功
[dave01@rhce ~]$ dd if=/dev/zeroof=/dave/tf01 bs=1M count=5
5+0 records in
5+0 records out
5242880 bytes (5.2 MB) copied, 0.0445553 s,118 MB/s
?
--創建10M的文件,超過soft 的配額限制,有警告:
[dave01@rhce ~]$ dd if=/dev/zeroof=/dave/tf01 bs=1M count=10
sdc1: warning, user blockquota exceeded.
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.0232663 s,451 MB/s
?
--在創建10M的文件,超過20M的配額限制,文件創建失敗:
[dave01@rhce ~]$ dd if=/dev/zeroof=/dave/tf02 bs=1M count=10
sdc1: write failed, userblock limit reached.
dd: writing `/dave/tf02':Disk quota exceeded
10+0 records in
9+0 records out
10448896 bytes (10 MB) copied, 0.049051 s,213 MB/s
[dave01@rhce ~]$
?
--查看報告:
[root@rhce dave]# repquota /dave
*** Report for user quotas on device/dev/sdc1
Block grace time: 7days;Inode grace time: 7days
??????????????????????? Block limits??????????????? File limits
User??????????? used??? soft???hard? grace??? used?soft? hard? grace
----------------------------------------------------------------------
root?????--? 141432?????? 0??????0????????????? 3???? 0????0??????
dave01??? +-??20480?? 10240?? 20480?6days?????? 3???? 0????0??????
?
這里就顯示了dave01這個用戶的相關限制。我們這里的寬限時間變成了6days。
?
?
2.6 配置文件個數的配額限制
?
配額的限制,除了在磁盤大小上的限制,還可以在文件個數上進行限制。我們這里用dave02這個進行示例。
?
[root@rhce dave]# edquota -u dave02
Disk quotas for user dave02 (uid 504):
?Filesystem??????????????????blocks?????? soft?????? hard????inodes???? soft???? hard
?/dev/sdc1????????????????????????0????????? 0????????? 0?????????0???? ??20??????30
?
?
soft和hard同上是軟限制和硬限制,分別是20、30,當用戶dave02創建文件超過20個時,系統會進行提示,但仍可以繼續創建文件,而當用戶dave02創建文件超過30個文件時,就會限制用戶dave02繼續創建文件。
?
注意:因為用戶dave02是在/dave目錄下進行了磁盤配額限制,所以/dave目錄會算做一個文件,所以dave02最多只能創建29個文件。
?
[root@rhce ~]# chown dave02.grp02 /dave
?
?
--用腳本手動創建文件:
?
[dave02@rhce ~]$ cd /dave
[dave02@rhce dave]$ ls
aquota.group? aquota.user?lost+found? tf01? tf02
[dave02@rhce dave]$
?
[dave02@rhce dave]$ for i in $(seq 1 22);
> do echo “dave02file$i”;
> touch dave02file$i;
> done
“dave02file1”
“dave02file2”
“dave02file3”
“dave02file4”
“dave02file5”
“dave02file6”
“dave02file7”
“dave02file8”
“dave02file9”
“dave02file10”
“dave02file11”
“dave02file12”
“dave02file13”
“dave02file14”
“dave02file15”
“dave02file16”
“dave02file17”
“dave02file18”
“dave02file19”
“dave02file20”
sdc1: warning, user filequota exceeded.
“dave02file21”
“dave02file22”
[dave02@rhce dave]$
?
到20就提示配額限制了。
?
--繼續用腳本創建文件:
?
[dave02@rhce dave]$ for i in $(seq 23 33);
> do echo “dave02file$i”;
> touch dave02file$i;
> done
“dave02file23”
“dave02file24”
“dave02file25”
“dave02file26”
“dave02file27”
“dave02file28”
“dave02file29”
“dave02file30”
sdc1: write failed, userfile limit reached.
touch: cannot touch`dave02file30': Disk quota exceeded
“dave02file31”
touch: cannot touch `dave02file31': Diskquota exceeded
“dave02file32”
touch: cannot touch `dave02file32': Diskquota exceeded
“dave02file33”
touch: cannot touch `dave02file33': Diskquota exceeded
[dave02@rhce dave]$
?
?
這里我們最多只能創建29個文件。
?
?
--限制報告:
[root@rhce ~]# repquota /dave
*** Report for user quotas on device/dev/sdc1
Block grace time: 7days;Inode grace time: 7days
??????????????????????? Block limits??????????????? File limits
User??????????? used??? soft???hard? grace??? used?soft? hard? grace
----------------------------------------------------------------------
root?????--? 141432?????? 0??????0????????????? 3???? 0????0??????
dave01???+-?? 20476?? 10240??20480? 6days?????? 2????0???? 0??????
dave02???-+?????? 4?????? 0??????0???????????? 30??? 20??? 30?6days
?
?
2.7 更改寬限時間
?
通過repquota命令,可以看到block和inode的寬限時間默認都是7天。
[root@rhce ~]# repquota /dave
*** Report for user quotas on device/dev/sdc1
Block grace time: 7days;Inode grace time: 7days
?
這個時間,我們可以使用edquota 來修改。
?
[root@rhce ~]# edquota -h
edquota: Usage:
???????edquota [-rm] [-u] [-F formatname] [-p username] [-f filesystem]username ...
???????edquota [-rm] -g [-F formatname] [-p groupname] [-f filesystem]groupname ...
???????edquota [-rm] [-u|g] [-F formatname] [-f filesystem] -t
???????edquota [-rm] [-u|g] [-F formatname] [-f filesystem] -Tusername|groupname ...
?
-u, --user??????????????????? edit user data
-g, --group?????????????????? edit group data
-r, --remote????????????????? edit remote quota (via RPC)
-m, --no-mixed-pathnames????? trim leading slashes from NFSv4mountpoints
-F, --format=formatname?????? edit quotas of a specific format
-p, --prototype=name????????? copy data from a prototype user/group
???--always-resolve????????? alwaystry to resolve name, even if it is
????????????????? ????????????composed only of digits
-f, --filesystem=filesystem?? edit data only on a specific filesystem
-t, --edit-period???????????? edit grace period
-T, --edit-times????????????? edit grace time of a user/group
-h, --help??????????????????? display this help text andexit
-V, --version???????????????? display version informationand exit
?
2.7.1 按用戶來設置寬限時間
--修改用戶dave01的寬限時間:
?
[root@rhce ~]# edquota-T dave01
Times to enforce softlimit for user dave01(uid 503):
Time units may be: days, hours, minutes, orseconds
?Filesystem????????????????????????block grace?????????????? inodegrace
?/dev/sdc1???????????????????????? 601938seconds? ????????????????unset
~
這是默認值:
?
[root@rhce ~]# edquota -T dave01
Times to enforce softlimit for user dave01(uid 503):
Time units may be: days,hours, minutes, or seconds
?Filesystem????????????????????????block grace?????????????? inodegrace
?/dev/sdc1??????????????????????????10days? ??????????????unset
?
我們改成10天。 上面有時間的單位。
?
--查看報告顯示:
[root@rhce ~]# repquota /dave
*** Report for user quotas on device/dev/sdc1
Block grace time: 7days; Inode grace time:7days
??????????????????????? Block limits??????????????? File limits
User??????????? used??? soft???hard? grace??? used?soft? hard? grace
----------------------------------------------------------------------
root?????--? 141432?????? 0??????0????????????? 3???? 0????0??????
dave01???+-?? 20476?? 10240??20480 10days ??????2????0???? 0??????
dave02???-+?????? 4?????? 0??????0???????????? 30??? 20???30? 6days
?
?
[root@rhce ~]# edquota -T dave02
Times to enforce softlimit for user dave02(uid 504):
Time units may be: days, hours, minutes, orseconds
?Filesystem????????????????????????block grace?????????????? inodegrace
?/dev/sdc1????????????????????????????????unset?????????????? 12days
~
[root@rhce ~]# repquota/dave
*** Report for user quotas on device/dev/sdc1
Block grace time: 7days; Inode grace time:7days
??????????????????????? Block limits??????????????? File limits
User??????????? used??? soft???hard? grace??? used?soft? hard? grace
----------------------------------------------------------------------
root?????--? 141432?????? 0??????0????????????? 3???? 0????0??????
dave01???+-?? 20476?? 10240??20480? 9days?????? 2????0???? 0??????
dave02???-+?????? 4?????? 0??????0???????????? 30??? 20???30 12days
?
?
2.7.2 按組來設置寬限時間
?
我們的dave02 用戶對應的組是grp02.
?
-Tg 爭對組
T 爭對用戶
?
--默認值:
[root@rhce ~]# edquota -Tg grp02
Times to enforce softlimit for group grp02(gid 504):
Time units may be: days,hours, minutes, or seconds
?Filesystem????????????????????????block grace?????????????? inodegrace
?/dev/sdc1????????????????????????????????unset????????????????? unset
?
?
?
--修改:
[root@rhce ~]# edquota -Tg grp02
Times to enforce softlimit for group grp02(gid 504):
Time units may be: days, hours, minutes, orseconds
?Filesystem????????????????????????block grace?????????????? inodegrace
?/dev/sdc1????????????????????????????????unset???????????????? 10days
?
~
?
但是這里我們一旦保存之后,我們的修改就又還原了。
?
如果我們想修改組的寬限時間,就必須先設置組的soft和hard limit。 只有這2個屬性設置以后,才可以設置寬限時間。
?
[root@rhce dave]# edquota-g grp02
Disk quotas for group grp02 (gid 504):
?Filesystem??????? ???????????blocks?????? soft?????? hard????inodes???? soft???? hard
?/dev/sdc1????????????????????????4????????? 0????????? 0???????? 30??????? 20??????? 30
?
這是完以后,就可以設置組的寬限時間了。
?
?
?
?
2.8 關閉配額
[root@rhce dave]# quotaoff -a
?
--關閉quota之后,在清空/etc/fstab 文件中有關配額的限制。
?
最后remount 磁盤。
?
?
?
?
?
?
?
?
?
?
---------------------------------------------------------------------------------------
版權所有,文章允許轉載,但必須以鏈接方式注明源地址,否則追究法律責任!
Skype: ???tianlesoftware
QQ:???? ? tianlesoftware@gmail.com
Email: ???tianlesoftware@gmail.com
Blog:?? ? http://blog.csdn.net/tianlesoftware
Weibo: ???http://weibo.com/tianlesoftware
Twitter:? http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware
轉載于:https://www.cnblogs.com/tianlesoftware/p/3609060.html
總結
以上是生活随笔為你收集整理的Linux 用户 quote 配置 说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么要学数学、语文?还有英语!
- 下一篇: 知识图谱-KGE-模型:概述【KGE模型