RHEL7設置磁盤配額

磁盤配額
RHEL7磁盤配額
確認配額命令已經安裝
[root@localhost ~]# rpm -qf which xfs_quota
xfsprogs-3.2.2-2.el7.x86_64

首先創建新的測試分區/dev/sdb3

啓用配額
[root@localhost ~]# mkfs.xfs /dev/sdb3
[root@localhost ~]# mkdir /sdb3
[root@localhost ~]# mount -o uquota,gquota /dev/sdb3 /sdb3/
查看:
[root@localhost ~]# mount | grep sdb3
/dev/sdb3 on /sdb3 type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)

如何開機自動啓動配額
[root@localhost ~]# vim /etc/fstab
/dev/sdb3 /sdb3 xfs defaults,usrquota,grpquota 0 0

設置目錄權限,並創建配額用戶
[root@localhost ~]# chmod 777 /sdb3/
[root@localhost ~]# useradd u01

查看配額狀態
[root@localhost ~]# xfs_quota -x -c 'report' /sdb3/
User quota on /sdb3 (/dev/sdb3)
Blocks
User ID Used Soft Hard Warn/Grace


root 0 0 0 00 [--------]

Group quota on /sdb3 (/dev/sdb3)
Blocks
Group ID Used Soft Hard Warn/Grace


root 0 0 0 00 [--------]

參數:
-x 使用專家模式,只有此模式才能設置配額
-c 啓用命令模式
report 顯示配額信息
limit 設置配額

設置配額
[root@localhost ~]# xfs_quota -x -c 'limit bsoft=100M bhard=120M -u u01' /sdb3/
[root@localhost ~]# xfs_quota -x -c 'report' /sdb3/
User quota on /sdb3 (/dev/sdb3)
Blocks
User ID Used Soft Hard Warn/Grace


root 0 0 0 00 [--------]
swk 0 102400 122880 00 [--------]

驗證:
[root@localhost ~]# su - u01
[swk@localhost ~]$ dd if=/dev/zero of=/sdb3/u01.txt bs=1M count=130
dd: error writing ‘/sdb3/swk.txt’: Disk quota exceeded
121+0 records in
120+0 records out
125829120 bytes (126 MB) copied, 0.426091 s, 295 MB/s

[root@localhost ~]# ll -h /sdb3/u01.txt
-rw-rw-r-- 1 u01 u01 120M Feb 27 09:21 /sdb3/u01.txt

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章