如題,創建的pvc并無法控制用戶實際使用多少nfs存儲,使用xfs_quota來對用戶nfs目錄做磁盤配額管理
1、需使用xfs文件系統
2、/etc/fstab掛載中開啟prjquota(項目配額)
具體操作如下
xfs_quota 使用說明/etc/fstab掛載磁盤
UUID="bd49b6be-1439-43f7-a6a6-dbec452dd236" /testxfs xfs defaults,prjquota 0 0#分配項目ID和目錄 (一個路徑一個ID)
echo "100:/testxfs/3G" >>/etc/projects
echo "3G:100" >>/etc/projidxfs_quota -x -c 'project -s 3G' /testxfs
Setting up project 3G (path /testxfs/3G)...
Processed 1 (/etc/projects and cmdline) paths for project 3G with recursion depth infinite (-1).#設置配額為3G
xfs_quota -x -c 'limit -p bhard=3g 3G' /testxfsxfs_quota -x -c 'report -h' /testxfs
Project quota on /testxfs (/dev/mapper/nasvg-test)Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 7G 0 0 00 [------]
3G 0 0 3G 00 [------]===========================================
[root@node01 3G]# dd if=/dev/zero of=3g_file bs=1G count=3
記錄了3+0 的讀入
記錄了3+0 的寫出
3221225472字節(3.2 GB,3.0 GiB)已復制,3.59724 s,895 MB/s
[root@node01 3G]# dd if=/dev/zero of=1g_file bs=1G count=3
dd: 打開'1g_file' 失敗: 超出磁盤限額[root@node01 3G]# df -h | grep xfs
/dev/mapper/nasvg-test 8.0G 3.1G 5.0G 39% /testxfs
[root@node01 3G]# pwd
/testxfs/3Gxfs_quota -x -c 'report -h' /testxfs
Project quota on /testxfs (/dev/mapper/nasvg-test)Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
3G 3G 0 3G 00 [------]