1.#####磁盘配额###
新建磁盘设备vdb1,并格式化
[root@localhost ~]# mount -o usrquota,grpquota /dev/vdb1 /pub ####建立用户与用户组的磁盘空间配额
[root@localhost ~]# quotaon -ugv /dev/vdb1 ######开启磁盘配额功能
quotaon: Enforcing group quota already on /dev/vdb1
quotaon: Enforcing user quota already on /dev/vdb1
[root@localhost ~]# edquota -u student ######编辑student用户的配额
>>Disk quotas for user student (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/vdb1 0 10240 51200 0 0 3 #####限制用户使用1M会发出警报,50M禁止使用,实际使用0M,最多允许拥有3个文件数量
[student@localhost ~]$ dd if=/dev/zero of=/pub/file bs=40M count=1
1+0 records in
1+0 records out
41943040 bytes (42 MB) copied, 0.0425372 s, 986 MB/s
[student@localhost ~]$ du -sh /pub/file
40M /pub/file
[student@localhost ~]$ dd if=/dev/zero of=/pub/file bs=60M count=1
dd: error writing ‘/pub/file’: Disk quota exceeded #####大于配额时报错
1+0 records in
0+0 records out
52428800 bytes (52 MB) copied, 0.0496774 s, 1.1 GB/s
[student@localhost ~]$ du -sh /pub/file
50M /pub/file #########只截取50M
2.###############查看配额使用情况#############
[student@localhost ~]$ quota ##########用户端
Disk quotas for user student (uid 1000):
Filesystem blocks quota limit grace files quota limit grace
/dev/vdb1 51200* 10240 51200 6days 1 0 3
[root@localhost ~]# repquota -a ##########超级用户端
*** Report for user quotas on device /dev/vdb1
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 0 0 0 3 0 0
student +- 51200 10240 51200 6days 1 0 3
[root@localhost ~]# quotaoff -ugv /dev/vdb1 #########关闭配额功能
Disabling group quota enforcement on /dev/vdb1
/dev/vdb1: group quotas turned off
Disabling user quota enforcement on /dev/vdb1
/dev/vdb1: user quotas turned off
3.#########永久配额########
[student@localhost ~]$ vim /etc/fstab
......
/dev/vdb1 /pub xfs defaults,usrquota,grpquota 0 0 ####开机自动挂载并建立用户和用户组的磁盘空间配额