d、启动文件系统的磁盘配额功能
quotaon -ugv 文件系统 //启用配额
quotaoff -ugv 文件系统 //关闭配额
例如:
[root@localhost ~]# quotaon -ugv /mailbox/
/dev/mapper/mail_store-mbox [/mailbox]: group quotas turned on
/dev/mapper/mail_store-mbox [/mailbox]: user quotas turned on
e、验证磁盘配额功能
要求:必须使用限制配额的用户登录同时进入设置配额的文件系统中(必须保证限制配额的用户对设置配额的文件系统由写的权限)
例如:
[root@localhost ~]# su - bob
[bob@localhost ~]$ cd /mailbox/
[bob@localhost mailbox]$ dd if=/dev/zero of=myfile.txt bs=1M count=100
dm-2: warning, user block quota exceeded.
dm-2: write failed, user block limit reached.
dd: 正在写入"myfile.txt": 超出磁盘限额
记录了98+0 的读入
记录了97+0 的写出
102400000字节(102 MB)已复制,0.384537 秒,266 MB/秒
f、查看用户或分区的配额使用情况
用户的角度:
quota -u 用户账户
quota -g 组账户
例如:
[root@localhost ~]# quota -u bob
Disk quotas for user bob (uid 500):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/mail_store-mbox
100000* 80000 100000 6days 1 0 0
分区使用情况的角度:
repquota 文件系统
例如:
[root@localhost ~]# repquota /mailbox/
*** Report for user quotas on device /dev/mapper/mail_store-mbox
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20 0 0 2 0 0
bob +- 100000 80000 100000 6days 1 0 0