k8s使用自建nfs做持久化无法控制磁盘使用大小问题处理

如题,创建的pvc并无法控制用户实际使用多少nfs存储,使用xfs_quota来对用户nfs目录做磁盘配额管理

1、需使用xfs文件系统

2、/etc/fstab挂载中开启prjquota(项目配额)

具体操作如下

powershell 复制代码
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 [------]
相关推荐
武子康1 天前
调查研究-183 Apple container:Mac 上用轻量 VM 跑 Linux 容器,Swift 会改写本地容器体验吗?
docker·容器·apple
秋播2 天前
国内本地WSL2编译rancher源码
云原生
小猿姐3 天前
MySQL Top 10 热点问题 AI 运维实战:从内核诊断到云原生运维
mysql·云原生·aiops
阿里云云原生4 天前
深入内核:拆解 OpenTelemetry eBPF 探针如何优雅地“透视”多语言微服务?
云原生
2601_961875245 天前
决战申论100题2026|最新|范文
linux·容器·centos·debian·ssh·fabric·vagrant
java_cj5 天前
深入kube-apiserver认证机制:从Bearer Token到mTLS的完整认证链解析
linux·运维·服务器·云原生·容器·kubernetes
程序员老赵5 天前
服务器没有桌面?Docker 跑个 Chrome,浏览器就能远程用
docker·容器·devops
正经教主5 天前
【docker基础】 第八周:容器监控与应用更新策略
运维·docker·容器
kiros_wang5 天前
Docker 使用完整指南
运维·docker·容器
正经教主5 天前
【docker基础】第九周:Docker安全与镜像优化
运维·docker·容器