如题,创建的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/projid

xfs_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' /testxfs


xfs_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/3G

xfs_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 [------]



Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐