RHEL7设置磁盘配额

磁盘配额
RHEL7磁盘配额
确认配额命令已经安装
[root@localhost ~]# rpm -qf which 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/Grace


root 0 0 0 00 [--------]

Group quota on /sdb3 (/dev/sdb3)
Blocks
Group ID Used Soft Hard Warn/Grace


root 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/Grace


root 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

转载于:https://blog.51cto.com/11638205/2049122

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值