設定檔案系統配額
vim /etc/fstab
挂載選項中添加usrquota(針對使用者),grpquota(針對組)
mount -o remount,rw /home
cd /home
#建立磁盤配額資料庫(u對應usrquota,g對應grpquota)
#關閉selinux
setenforce 0
#建立磁盤配額資料庫
quotacheck -cug /home #生成aquota.group和aquota.user檔案
# 啟用配額
quotaon /home
#檢視狀态
quotaon -p /home
useradd quotatest
#編輯磁盤配額
edquota quotatest
Disk quotas for user quotatest (uid 1002):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 16 0 0 10 9 10
blocks以K為機關 soft為警報值.hard為限制值,blocks和inodes表示此使用者已用值;0代表不限制;改變檔案所有者,已用值将釋放
#設定組
edquota -g group1
newgrp group1 #切換到該組測試
# 非互動方式設定
setquota [ -u|-g ] 裝載點 軟塊數 硬塊數 軟檔案數 硬檔案數 使用者名/組名
setquota lee 20000 30000 70 80 /home
setquota -g lee 20000 25000 60 70 /home
#磁盤配額的參考設定
edquota -p quotatest lee #參考使用者quotatest的設定lee的磁盤配額
#檢視統計資訊
repquota /home #檢視使用者
repquota -g /home #檢視組
以檔案挂載設定配額
#建立檔案
dd if=/dev/zero of=test7 bs=4k count=1000000
#指定檔案系統
mkfs.ext4 ./test7
#挂載quota項
mount -o usrquota,grpquota,loop /mnt/test7 /home/test7
cd /home /test7
setenforce 0
quotacheck -cug ./
quotaon ./
quotaon -p ./
repquota ./
以目錄挂載設定配額
mount -B -o usrquota,grpquota /home/test0 /mnt/test0
巧用軟連結設定磁盤配額
如果對var/pool/mail中的檔案做配額,不必重新挂載其所在的分區,隻需建立一個軟連結至一個有已添加quto挂載選項的分區
設定項 | XFS檔案系統 | EXT家族 |
---|---|---|
/etc/fstab參數設定 | usrquota/grpquota/prjquota | usrquota/grpquota |
quota 設定檔 | 不需要 | quotacheck |
設定用戶/群組限制值 | xfs_quota -x -c “limit…” | edquota 或 setquota |
設定 grace time | xfs_quota -x -c “timer…” | edquota |
設定目錄限制值 | xfs_quota -x -c “limit…” | 無 |
檔案報告 | xfs_quota -x -c “report…” | repquota 或 quota |
開關 quota 限制 | xfs_quota -x -c" [disable | enable]…" |
發送警告給用戶 | 目前版本尚未支援 | warnquota |
關注擷取最新優質文章