创建quota:
[root@localhost ~]# mount | grep home
/dev/mapper/centos1-home on /home type ext4 (rw,relatime,seclabel,data=ordered)
[root@localhost ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 10 15:41:09 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=68f515a6-6aed-4a7f-ab5c-e43d73c2b694 / ext4 defaul
ts 1 1
UUID=7cd7a3f0-5ac7-4e5d-9036-f61a72c7d276 /boot xfs defaul
ts 0 0
/dev/mapper/centos1-home /home
ext4 defaults,usrquota,grpqu
ota 1 2
UUID=a5a2976e-1b4c-4ef1-a869-aad8022a2526 swap swap defaul
ts 0 0
~
~
~
~
~
~
~
~
~
~
~
~
~
-- INSERT -- 11,84 All
#
# /etc/fstab
# Created by anaconda on Tue Apr 10 15:41:09 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=68f515a6-6aed-4a7f-ab5c-e43d73c2b694 / ext4 defaults 1 1
UUID=7cd7a3f0-5ac7-4e5d-9036-f61a72c7d276 /boot xfs defaults 0 0
/dev/mapper/centos1-home /home ext4 defaults,usrquota,grpquota 1 2
UUID=a5a2976e-1b4c-4ef1-a869-aad8022a2526 swap swap defaults 0 0
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/fstab" 12L, 596C written
[root@localhost ~]# umount /home
[root@localhost ~]# mount -a
[root@localhost ~]# mount | grep home
/dev/mapper/centos1-home on /home type ext4 (rw,relatime,seclabel,quota,usrquota,grpquota,data=ordered)
[root@localhost ~]# quotacheck -avug
quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
quotacheck: Scanning /dev/mapper/centos1-home [/home] done
quotacheck: Cannot stat old user quota file /home/aquota.user: No such file or directory. Usage will not be subtracted.
quotacheck: Cannot stat old group quota file /home/aquota.group: No such file or directory. Usage will not be subtracted.
quotacheck: Cannot stat old user quota file /home/aquota.user: No such file or directory. Usage will not be subtracted.
quotacheck: Cannot stat old group quota file /home/aquota.group: No such file or directory. Usage will not be subtracted.
quotacheck: Checked 10 directories and 10 files
quotacheck: Old file not found.
quotacheck: Old file not found.
[root@localhost ~]# quotaon -avug
/dev/mapper/centos1-home [/home]: group quotas turned on
/dev/mapper/centos1-home [/home]: user quotas turned on
给用户1 限额:
[root@localhost ~]# edquota -u vbirduser1
Disk quotas for user vbirduser1 (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/centos1-home 36 1800000 2000000 9 0 0
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/tmp/EdP.aXRbQyW" 3L, 226C written
[root@localhost ~]# edquota -p vbirduser1 vbirduser2
查看:
[root@localhost ~]# repquota -au
*** Report for user quotas on device /dev/mapper/centos1-home
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 24 0 0 3 0 0
vbirduser1 -- 36 1800000 2000000 9 0 0
vbirduser2 -- 16 1800000 2000000 4 0 0
vbirduser3 -- 16 0 0 4 0 0
[root@localhost ~]# edquota -p vbirduser1 vbirduser3
[root@localhost ~]# repquota -au
*** Report for user quotas on device /dev/mapper/centos1-home
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 24 0 0 3 0 0
vbirduser1 -- 36 1800000 2000000 9 0 0
vbirduser2 -- 16 1800000 2000000 4 0 0
vbirduser3 -- 16 1800000 2000000 4 0 0
[root@localhost ~]#
用户1登陆linux测试下:
[16:55:59]Last login: Tue Apr 10 16:21:25 2018 from 135.251.214.227
[16:55:59][vbirduser1@localhost ~]$
[16:56:00][vbirduser1@localhost ~]$
[16:56:55][vbirduser1@localhost ~
]$ dd if=/dev/zero of=hello.txt bs=50000M count=1
[16:56:59]
[16:57:04]dm-0: warning, us
er block quota exceeded.
[16:57:04]dm-0: write failed, user block limit reached.
[16:57:04]dd: error writing ‘hello.txt’: Disk quota exceeded
[16:57:04]0+1 records in
[16:57:04]0+0 records out
[16:57:04]2047963136 bytes (2.0 GB) copied, 9.53004 s, 215 MB/s
[16:57:05][vbirduser1@localhost ~]$
[16:57:18][vbirduser1@localhost ~]$ ls
[16:57:18]hello.txt
[16:57:21][vbirduser1@localhost ~]$ ll
[16:57:21]total 1999968
[16:57:21]-rw-rw-r--. 1 vbirduser1 vbirduser1 2047963136 Apr 10 17:09 hello.txt
[16:57:35][vbirduser1@localhost ~]$ ls -h
[16:57:35]hello.txt
[16:57:40][vbirduser1@localhost ~]$ ll -h
[16:57:40]total 2.0G
[16:57:40]-rw-rw-r--. 1 vbirduser1 vbirduser1 2.0G Apr 10 17:09 hello.txt
[16:57:51][vbirduser1@localhost ~]$ pwd
[16:57:51]/home/vbirduser1
[16:57:58][vbirduser1@localhost ~]$ rm -rf hello.txt
[16:58:43][vbirduser1@localhost ~]$ logoff
[16:58:43]-bash: logoff: command not found
[16:58:47][vbirduser1@localhost ~]$ exit
[16:58:47]logout