1 启用配额限制 vim /etc/fstab
UUID=”5263027d-f571-4c4a-98d8-930e41e0e265″ /home ext4 usrquota,grpquota 0 0
[root@localhost ~]# mount -o remount /home
[root@localhost home]# ls
fsy lost+found mage
2创建配额数据库
[root@localhost home]# mount
[root@localhost home]# mount -o remount /home
[root@localhost home]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext=”system_u:object_r:tmpfs_t:s0″)
/dev/sda6 on /app type ext4 (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /home type ext4 (rw)
/dev/sdc1 on /home type ext4 (rw,usrquota,grpquota) // 这一行必须生效
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost home]# quotacheck -cug /home // c-create 创建的意思 u=user 用户 g=group用户组
[root@localhost home]# ls
aquota.group aquota.user fsy lost+found mage
[root@localhost home]# quotaon /home // 启用磁盘数据库
[root@localhost home]# edquota fsy // 设置 fsy用户
Disk quotas for user fsy (uid 500):
Filesystem blocks soft hard inodes soft hard
/dev/sdc1 32 80000 100000 8 0 0
3 测试
[root@localhost home]# su fsy
[fsy@localhost home]$ cd /home/fsy
[fsy@localhost ~]$ touch f1
[fsy@localhost ~]$ dd if=/dev/zero of=f1 bs=1M count=500
sdc1: warning, user block quota exceeded.
sdc1: write failed, user block limit reached.
dd: writing `f1′: Disk quota exceeded
98+0 records in
97+0 records out
102367232 bytes (102 MB) copied, 0.216797 s, 472 MB/s
[fsy@localhost ~]$ dd if=/dev/zero of=f1 bs=1M count=900
dd: writing `f1′: Disk quota exceeded
98+0 records in
97+0 records out
102367232 bytes (102 MB) copied, 1.10981 s, 92.2 MB/s
[fsy@localhost ~]$ dd if=/dev/zero of=f1 bs=1M count=90
sdc1: warning, user block quota exceeded.
90+0 records in
90+0 records out
94371840 bytes (94 MB) copied, 0.411171 s, 230 MB/s
[fsy@localhost ~]$ ll f1 -h
-rw-rw-r–. 1 fsy fsy 90M Apr 25 17:40 f1
原创文章,作者:fsy,如若转载,请注明出处:http://www.178linux.com/74267