一、安装
yum install quota
二、配置
1、创建一个新的分区 sdb1并格式化
2、
[[email protected] /]# mkdir /common
[[email protected] /]# mount /dev/sdb1 /common/
[[email protected] /]# mount
/dev/sdb1 on /common type ext4 (rw)
发现属性只有rw
[[email protected] /]# mount -o remount,usrquota /dev/sdb1
/dev/sdb1 on /common type ext4 (rw,usrquota)
看到属性添加了userquota
[[email protected] /]# mount -o remount,usrquota,grpquota /dev/sdb1
[[email protected] /]# mount
/dev/sdb1 on /common type ext4 (rw,usrquota,usrquota,grpquota)
属性添加了grpquota
[[email protected] /]# umount /dev/sdb1
一步完成:
[[email protected] /]# mount -o usrquota,grpquota /dev/sdb1 /common/
!!!关闭防火墙
[[email protected] /]# quotacheck /common/
配置一个用户的配额
[[email protected] common]# edquota -u redhat
Disk quotas for user redhat (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 0 204800 409600 0 0 0
软限制为200M 硬限制为400M
[[email protected] common]# quotaon /common
[[email protected] common]# quotacheck /common
[[email protected] common]# quotaon /common/
[[email protected] /]# chmod o+w common/
[[email protected] common]# su - redhat
[[email protected] common]$ touch abc
看到redhat用户有创建文件的权限
现在可以验证了
[[email protected] common]$ dd if=/dev/zero of=redhat_file bs=1M count=500
sdb1: warning, user block quota exceeded.
sdb1: write failed, user block limit reached.
dd: writing `redhat_file‘: Disk quota exceeded
401+0 records in
400+0 records out
419430400 bytes (419 MB) copied, 17.6664 s, 23.7 MB/s
[[email protected] common]$
sdb1: warning, user block quota exceeded. 为软限制发出的警告
sdb1: write failed, user block limit reached. 硬限制起作用,一共创建401个
,大小为419M
也可以限制用户的inodes
[[email protected] common]# edquota -u redhat
Disk quotas for user redhat (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdb1 409600 204800 409600 2 200 1000
设置inodes软限制为200 硬限制为1000
使用quota -u 进行查看
[[email protected] common]# quota -u redhat
Disk quotas for user redhat (uid 500):
Filesystem blocks quota limit grace files quota limit grace
/dev/sdb1 409600* 204800 409600 7days 2 200 1000
以redhat身份登录进行查看
[[email protected] common]# su - redhat
[[email protected] ~]$ quota -s (-s 便于人查看)
Disk quotas for user redhat (uid 500):
Filesystem blocks quota limit grace files quota limit grace
/dev/sdb1 409600* 204800 409600 6days 2 200 100
[[email protected] redhat]# mount -o remount,usrquota,grpquota /common/
/dev/sdb1 on /common type ext4 (rw,usrquota,grpquota)
[[email protected] redhat]# quotaoff /common
[[email protected] redhat]# cd /common/
[[email protected] common]# rm -rf *
[[email protected] common]# quotacheck /common/
[[email protected] common]# ls
aquota.user
[[email protected] common]# quotacheck -g /common/
[[email protected] common]# ls
aquota.group aquota.user
[[email protected] common]# edquota -g redhat
编辑redhat组的配额