xfs文件系统磁盘配额管理
环境:Centos7.4_x64
xfs文件系统
1、安装配额工具(如果已安装跳过此步)
[root@localhost ~]# yum -y install quota
2、查看当前配额是否开启
[root@localhost ~]# mount |grep quota
/dev/sda3 on / type xfs (rw,relatime,attr2,inode64,noquota) /dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota) /dev/mapper/vg0-lv0 on /data type xfs (rw,relatime,attr2,inode64,noquota)
3、开启配额
命令格式: mount -o uquota,gquota [设备] [挂载点]
[root@localhost ~]# mount -o uquota,gquota /dev/vg0/lv0 /data
[root@localhost ~]# mount |grep quota
/dev/mapper/vg0-lv0 on /data type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
4、开机自动开启配额并挂载
[root@localhost ~]# echo '/dev/vg0/lv0 /data xfs defaults,usrquota,grpquota 0 0'>> /etc/fstab
[root@localhost ~]# tail -1 /etc/fstab
/dev/vg0/lv0 /data xfs defaults,usrquota,grpquota 0 0
5、设置配额
命令:xfs_quota
命令格式:xfs_quota -x -c “指令” [挂载点]
xfs_quota -x -c “limit [-ug] b[soft|hard]=N i[soft|hard]=N ” [挂载点]
参数:
-x 使用配额模式,只有此模式才能设置配额
-c 启用命令模式
report 显示配额信息
limit 设置配额
bsoft 软限制 (硬盘)
bhard 硬配额
-u 用户
-g 组
例:
限制磁盘soft 10M,hard为15M,文件软限制个数为3个,硬限制为5个,用户为admin
[root@localhost ~]# xfs_quota -x -c 'limit bsoft=10M bhard=15M isoft=3 ihard=5 -u admin' /data
[root@localhost ~]# chmod 777 /data
6、查看配额信息
命令格式:xfs_quota -x -c report [挂载点]
[root@localhost ~]# xfs_quota -x -c report /data
User quota on /data (/dev/mapper/vg0-lv0) Blocks User ID Used Soft Hard Warn/Grace ---------- -------------------------------------------------- root 0 0 0 00 [--------] admin 0 10240 15360 00 [--------] Group quota on /data (/dev/mapper/vg0-lv0) Blocks Group ID Used Soft Hard Warn/Grace ---------- -------------------------------------------------- root 0 0 0 00 [--------]
7、查看状态信息
[root@localhost ~]# xfs_quota -x -c "print"
Filesystem Pathname / /dev/sda3 /boot /dev/sda1 /data /dev/mapper/vg0-lv0 (uquota, gquota)
8、验证
[root@localhost ~]# su - admin
[admin@localhost ~]$ dd if=/dev/zero of=/data/test.txt count=1K bs=10 [admin@localhost ~]$ dd if=/dev/zero of=/data/test2.txt count=1K bs=10 [admin@localhost ~]$ dd if=/dev/zero of=/data/test3.txt count=1K bs=10 [admin@localhost ~]$ dd if=/dev/zero of=/data/test4.txt count=1K bs=10 [admin@localhost ~]$ dd if=/dev/zero of=/data/test5.txt count=1K bs=10
[admin@localhost ~]$ dd if=/dev/zero of=/data/test6.txt count=1K bs=100 #上例中设定为5个文件 dd: 打开"/data/test6.txt" 失败: 超出磁盘限额
温馨提示:如无特殊说明,本站文章均为作者原创,转载请注明出处!