RHEL5 quota测试
1.编辑/etc/fstab使分区挂载的时候支持quota
LABEL=/home /home ext3 usrquota,grpquota ,defaults 1 2
2.扫瞄磁盘的使用者使用状况,并产生重要的 aquota.group 与 aquota.user
[root@redhat home]# quotacheck -ug /home
[root@redhat home]# ls -l
total 112
-rw------- 1 root root 7168 Nov 11 10:09 aquota.group
-rw------- 1 root root 7168 Nov 11 10:09 aquota.user
3.添加用户quotatest来进行quota测试
[root@redhat home]# useradd quotatest
4.edquota -u quotatest
Disk quotas for user quotatest (uid 504):
Filesystem blocks soft hard inodes soft hard
/dev/sda8 0 20000 20000 8 0 0
简单说明:红色那一组才是限制磁盘使用空间大小的,blocks不用管,默认0;soft和hard这下面两个值的单位是kb.
5.启用quota
[root@redhat home]# quotaon -a
6.测试
[quotatest@redhat ~]$ quota -vu
Disk quotas for user quotatest (uid 504):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda8 40 20000 30000 5 0 0
[quotatest@redhat ~]$ dd if=/dev/zero of=test.db1 bs=1024k count=12
12+0 records in
12+0 records out
12582912 bytes (13 MB) copied, 0.0510098 seconds, 247 MB/s
[quotatest@redhat ~]$ quota -vu
Disk quotas for user quotatest (uid 504):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda8 12348 20000 30000 6 0 0
[quotatest@redhat ~]$ dd if=/dev/zero of=test.db2 bs=1024k count=12
sda8: warning, user block quota exceeded.
12+0 records in
12+0 records out
12582912 bytes (13 MB) copied, 0.0429055 seconds, 293 MB/s
[quotatest@redhat ~]$ quota -vu
Disk quotas for user quotatest (uid 504):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda8 24656* 20000 30000 7days 7 0 0
[quotatest@redhat ~]$ dd if=/dev/zero of=test.db3 bs=1024k count=12
sda8: write failed, user block limit reached.
dd: writing `test.db3': Disk quota exceeded
6+0 records in
5+0 records out
5455872 bytes (5.5 MB) copied, 0.0195092 seconds, 280 MB/s
[quotatest@redhat ~]$ quota -vu
Disk quotas for user quotatest (uid 504):
Filesystem blocks quota limit grace files quota limit grace
/dev/sda8 30000* 20000 30000 8 0 0
[quotatest@redhat ~]$
附加:如果需要对大量用户进行相同的quota操作,可以使用以一命令进行quota复制
[root@redhat home]# edquota -p quotatest newuser