本文共 1554 字,大约阅读时间需要 5 分钟。
磁盘配额
RHEL7磁盘配额 确认配额命令已经安装 [root@localhost ~]# rpm -qfwhich xfs_quota
xfsprogs-3.2.2-2.el7.x86_64 首先创建新的测试分区/dev/sdb3
启用配额
[root@localhost ~]# mkfs.xfs /dev/sdb3 [root@localhost ~]# mkdir /sdb3 [root@localhost ~]# mount -o uquota,gquota /dev/sdb3 /sdb3/ 查看: [root@localhost ~]# mount | grep sdb3 /dev/sdb3 on /sdb3 type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)如何开机自动启动配额
[root@localhost ~]# vim /etc/fstab /dev/sdb3 /sdb3 xfs defaults,usrquota,grpquota 0 0设置目录权限,并创建配额用户
[root@localhost ~]# chmod 777 /sdb3/ [root@localhost ~]# useradd u01查看配额状态
[root@localhost ~]# xfs_quota -x -c 'report' /sdb3/ User quota on /sdb3 (/dev/sdb3) Blocks User ID Used Soft Hard Warn/Graceroot 0 0 0 00 [--------]
Group quota on /sdb3 (/dev/sdb3)
Blocks Group ID Used Soft Hard Warn/Graceroot 0 0 0 00 [--------]
参数:
-x 使用专家模式,只有此模式才能设置配额 -c 启用命令模式 report 显示配额信息 limit 设置配额设置配额
[root@localhost ~]# xfs_quota -x -c 'limit bsoft=100M bhard=120M -u u01' /sdb3/ [root@localhost ~]# xfs_quota -x -c 'report' /sdb3/ User quota on /sdb3 (/dev/sdb3) Blocks User ID Used Soft Hard Warn/Graceroot 0 0 0 00 [--------]
swk 0 102400 122880 00 [--------]验证:
[root@localhost ~]# su - u01 [swk@localhost ~]$ dd if=/dev/zero of=/sdb3/u01.txt bs=1M count=130 dd: error writing ‘/sdb3/swk.txt’: Disk quota exceeded 121+0 records in 120+0 records out 125829120 bytes (126 MB) copied, 0.426091 s, 295 MB/s[root@localhost ~]# ll -h /sdb3/u01.txt
-rw-rw-r-- 1 u01 u01 120M Feb 27 09:21 /sdb3/u01.txt本文转自信自己belive51CTO博客,原文链接: http://blog.51cto.com/11638205/2049122,如需转载请自行联系原作者