xfs磁盘限额
作者:
helphi | 来源:发表于
2020-04-09 21:23 被阅读0次# 安装磁盘限额工具
apt install quota
# 将磁盘 /dev/vdb 直接转为物理卷,转换后才能加到卷组中
pvcreate /dev/vdb
# 将磁盘 /dev/vdb 添加到卷组 vg 中,使用卷组是为了方便今后扩展磁盘
vgcreate vg /dev/vdb
# 将卷组 vg 中的所有空间分配到逻辑卷 lv 中
lvcreate -l 100%VG -n lv vg
# 此处格式化为 xfs 文件系统
mkfs.xfs /dev/vg/lv
# 将挂载信息写入fstab以便重启也可生效
echo "/dev/vg/lv /DATA xfs rw,pquota 0 0" >>/etc/fstab
# 由于还没重启,此处手工立即生效
mkdir /DATA
mount -a
# 使用配置文件做配额限制
echo "1:/DATA/dir1" >>/etc/projects
echo "dir1:1" >>/etc/projid
xfs_quota -x -c "project -s test" /DATA
xfs_quota -x -c 'limit -p bhard=1M dir1' /DATA
xfs_quota -x -c "report -pbih" /DATA
dd if=/dev/zero of=/DATA/dir1/file bs=2M count=1
# 不使用配置文件
xfs_quota -x -c "project -s -p dir2 2" /DATA
xfs_quota -x -c 'limit -p bhard=1M 2' /DATA
xfs_quota -x -c "report -pbih" /DATA
dd if=/dev/zero of=/DATA/dir2/file bs=2M count=1
# 删除id为2的配额记录
xfs_quota -x -c 'limit -p bhard=0 2' /DATA
# 查看状态
xfs_quota -x -c state
本文标题:xfs磁盘限额
本文链接:https://www.haomeiwen.com/subject/vmrxuhtx.html
网友评论