[root@localhost ~]# rpm -qa | grep quota
quota-3.17-23.el6.x86_64
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup 2 3 0 wz--n- 97.65g 16.82g
vms 2 2 0 wz--n- 97.65g 17.65g
[root@localhost ~]# lvcreate -L 10G -n quota_demo vms //新建lv用作测试
Logical volume "quota_demo" created.
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
quota_demo vms -wi-a----- 10.00g
[root@localhost ~]# mkfs.ext4 /dev/vms/quota_demo
[root@localhost ~]# mkdir /quota_demo //挂载点
[root@localhost ~]# mount /dev/mapper/vms-quota_demo /quota_demo/
[root@localhost ~]# echo "/dev/mapper/vms-quota_demo /quota_demo ext4 defaults,usrquota,grpquota 1 2" >> /etc/fstab
[root@localhost ~]# mount -a
[root@localhost ~]# mount -o remount /quota_demo/
[root@localhost ~]# mount -l
/dev/mapper/vms-quota_demo on /quota_demo type ext4 (rw,usrquota,grpquota)
[root@localhost ~]# quotacheck -vug /quota_demo/ //生成用户与组的磁盘配额数据库 也可使用-vu 或 -vg 单独生成 aquota.user aquota.group,可能需要关闭selinux,setenforce 0
[root@localhost ~]# ll /quota_demo/
[root@localhost ~]# useradd quota_demo //创建测试用户
[root@localhost ~]# quotaon /quota_demo/ //开启分区配额
[root@localhost ~]# setquota quota_demo 50M 200M 0 0 /quota_demo //设置quota_demo用户在测试分区的磁盘使用额, 50M 100M分别为Blocks的软硬配额,0 0为inodes,单位也可使用G,T
[root@localhost ~]# edquota quota_demo //查看
[quota_demo@localhost quota_demo]$ dd if=/dev/zero of=dd.iso bs=1M count=150
dm-5: warning, user block quota exceeded.
记录了150+0 的读入
记录了150+0 的写出
157286400字节(157 MB)已复制,0.172823 秒,910 MB/秒
[quota_demo@localhost quota_demo]$ dd if=/dev/zero of=dd1.iso bs=1M count=150
dm-5: write failed, user block limit reached.
dd: 正在写入"dd1.iso": 超出磁盘限额
记录了51+0 的读入
记录了50+0 的写出
52428800字节(52 MB)已复制,0.0658396 秒,796 MB/秒