root@centos6.9 ~]#mount /dev/sda2 on / type ext4 (rw) #因为有点多,所以我这里删除了几个挂载 proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) fuse.gvfs-fuse-daemon (rw,nosuid,nodev) /dev/sdb1 on /test type ext4 (rw,usrquota,grpquota) #()里的是挂载项rw表示这个分区可以读写,可以看到我们刚才添加的选项已经生效了
quotaon [-guvp] [-F quotaformat] [-x state] -a quotaon [-guvp] [-F quotaformat] [-x state] filesys #命令格式 [root@centos6.9 test]#quotaon /test/ #开启/test/的配额功能 [root@centos6.9 test]#quotaon -p /test/ #检查状态 group quota on /test (/dev/sdb1) is on #已经开启 user quota on /test (/dev/sdb1) is on
关闭磁盘配额:quotaoff 参数和quotaon的一样:
1 2 3
[root@centos6.9 test]#quotaoff -p /test/ #检查状态 group quota on /test (/dev/sdb1) is off #关闭状态 user quota on /test (/dev/sdb1) is off
Filesystem:文件系统名 blocks :已经使用的块数,一块等于1K soft :数据块的软限制,0表示禁用 hard :数据块的硬限制,0表示禁用,可用 inodes :已经创建的文件个数,如果有*表示超出软限制 soft :创建的文件个数的软限制,0表示禁用 hard :创建的文件个数的硬限制,0表示禁用 Disk quotas for user admin (uid 500): Filesystem blocks soft hard inodes soft hard /dev/sdb1 0 800 1M 0 8 10 #因为是测试所以只给了1M空间,和10文件,软限制给了800k和8个文件
实验文件大小限制:
1 2 3 4 5 6 7 8 9 10 11 12 13
[admin@centos6.9 test]$dd if=/dev/zero of=/test/1 bs=1M count=1 #创建1个1M的文件 sdb1: warning, user block quota exceeded. 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.00242046 s, 433 MB/s #创建成功 [admin@centos6.9 test]$ll -h #查看/test目录下的文件详细信息 drwx------. 2 root root 16K Jun 19 03:08 lost+found [admin@centos6.9 test]$dd if=/dev/zero of=/test/2 bs=1M count=1 #在创建1个文件2 sdb1: write failed, user block limit reached. dd: writing '/test/2': Disk quota exceeded #提示超过了磁盘配额 1+0 records in 0+0 records out 0 bytes (0 B) copied, 0.00140152 s, 0.0 kB/s #创建失败