CentOS关于quota的总结与实践详解

2020-01-30 16:26:38丽君

2.3.2 查询支持Quota的分区

xfs_quota -x -c "print"

2.3.3 查询Quota目录的使用情况

xfs_quota -x -c "df -h" /hom

2.3.4 显示用户的Quota的限制信息

xfs_quota -x -c "report -ubih" /home

注,显示项目加参数“-u”

2.4 配置限制

2.4.1 命令格式:

xfs_quota -x -c "limit [-ug] b[soft|hard]=N i[soft|hard]=N name"

xfs_quota -x -c "timer [-ug] [-bir] Ndays"

选项:

limit :限制的对象,包括user/group/project

bsoft/bhard : block的soft/hard限制值

isoft/ihard : inode的soft/hard限制值

name : 用户和组的名称

timer :宽限时间(grace time)

2.4.2 根据用户和块大小限制

xfs_quota -x -c "limit -u bsoft=250M bhard=300M user1" /home

xfs_quota -x -c "limit -u bsoft=250M bhard=300M user2" /home

检查配置:

xfs_quota -x -c "report -ubih" /home

2.4.3 根据组和块大小限制

xfs_quota -x -c "limit -g bsoft=950M bhard=1G gp1" /home

检查配置:

xfs_quota -x -c "report -gbih" /home

2.4.5 配置宽限时间

xfs_quota -x -c "timer -ug -b 14days" /home

验证配置:

xfs_quota -x -c "state" /home

2.4.6 验证Quta

su - user1

dd if=/dev/zero of=123.img bs=1M count=310

ll -h

exit

xfs_quota -x -c "report -ubh" /home

2.5 根据project限制

2.5.1 修改fstab

vim /etc/fstab

2.5.2 卸载挂载并重新挂载

umount /home

mount -a

2.5.3 检查取消

xfs_quota -x -c "state"

2.5.4 创建专案存储位置

mkdir /home/proj01

2.5.5 指定项目识别号

echo "01:/home/proj01" >> /etc/projects

2.5.6 指定项目名称并关联项目识别号

echo "proj01:01" >> /etc/projid

2.5.7 初始化项目名称

xfs_quota -x -c "project -s proj01"

检查配置:

xfs_quota -x -c "print " /home

xfs_quota -x -c "report -pbih " /home

2.5.8 根据块大小配置限制

xfs_quota -x -c "limit -p bsoft=450M bhard=500M proj01" /home

检查配置:

xfs_quota -x -c "report -pbih " /home

2.5.9 验证配置

dd if=/dev/zero of=/home/myquota/123.img bs=1M count=510

2.6 Quota的管理

2.6.1 临时禁用Quota限制

xfs_quota -x -c "disable -up" /home

检查禁用:

xfs_quota -x -c "state" /home

验证禁用:

dd if=/dev/zero of=/home/user1/123.img bs=1M count=520

查阅Quota状态:

xfs_quota -x -c "report -pbh" /home

清理测试文件:

rm -rf /home/user1/123.img

2.6.2 临时启动Quota限制