首页 > 代码库 > quota 磁盘配额
quota 磁盘配额
一、安装
yum install quota
二、配置
1、创建一个新的分区 sdb1并格式化
2、
[root@server05 /]# mkdir /common
[root@server05 /]# mount /dev/sdb1 /common/
[root@server05 /]# mount
/dev/sdb1 on /common type ext4 (rw)
发现属性只有rw
[root@server05 /]# mount -o remount,usrquota /dev/sdb1
/dev/sdb1 on /common type ext4 (rw,usrquota)
看到属性添加了userquota
[root@server05 /]# mount -o remount,usrquota,grpquota /dev/sdb1
[root@server05 /]# mount
/dev/sdb1 on /common type ext4 (rw,usrquota,usrquota,grpquota)
属性添加了grpquota
[root@server05 /]# umount /dev/sdb1
一步完成:
[root@server05 /]# mount -o usrquota,grpquota /dev/sdb1 /common/
!!!关闭防火墙
[root@server05 /]# quotacheck /common/
配置一个用户的配额
[root@server05 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
[root@server05 common]# quotaon /common
[root@server05 common]# quotacheck /common
[root@server05 common]# quotaon /common/
[root@server05 /]# chmod o+w common/
[root@server05 common]# su - redhat
[redhat@server05 common]$ touch abc
看到redhat用户有创建文件的权限
现在可以验证了
[redhat@server05 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
[redhat@server05 common]$
sdb1: warning, user block quota exceeded. 为软限制发出的警告
sdb1: write failed, user block limit reached. 硬限制起作用,一共创建401个
,大小为419M
也可以限制用户的inodes
[root@server05 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 进行查看
[root@server05 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身份登录进行查看
[root@server05 common]# su - redhat
[redhat@server05 ~]$ 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
[root@server05 redhat]# mount -o remount,usrquota,grpquota /common/
/dev/sdb1 on /common type ext4 (rw,usrquota,grpquota)
[root@server05 redhat]# quotaoff /common
[root@server05 redhat]# cd /common/
[root@server05 common]# rm -rf *
[root@server05 common]# quotacheck /common/
[root@server05 common]# ls
aquota.user
[root@server05 common]# quotacheck -g /common/
[root@server05 common]# ls
aquota.group aquota.user
[root@server05 common]# edquota -g redhat
编辑redhat组的配额
quota 磁盘配额