您的位置:首页 > 其它

设置ext4文件系统基于用户和组的磁盘限额

2018-01-17 19:18 363 查看
直接上程序[root@FQDN he]# vi /etc/fstab //编辑etc/fstab文件启动文件系统的quota挂装选项
[root@FQDN he]# mkfs.ext4 /dev/data/home
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 786432 blocks
39321 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
[root@FQDN he]# mount /dev/data/home /home
[root@FQDN he]# vi /etc/fstab
[root@FQDN he]# vi /etc/fstab
[root@FQDN he]# mount -o remount /home //重装文件系统
[root@FQDN he]# mount -a
[root@FQDN he]# quotacheck -cmvug /home
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/data-home [/home] done
quotacheck: Checked 2 directories and 2 files
[root@FQDN he]# vi /etc/fstab
[root@FQDN he]# quotacheck -cmvug /home //创建quota数据库文件并且启用quota
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/data-home [/home] done
quotacheck: Checked 2 directories and 2 files
[root@FQDN he]# quotaon -avug
/dev/mapper/data-home [/home]: group quotas turned on
/dev/mapper/data-home [/home]: user quotas turned on
[root@FQDN he]# ll /home/aquota*
-rw-------. 1 root root 6144 Jan 11 22:10 /home/aquota.group
-rw-------. 1 root root 6144 Jan 11 22:10 /home/aquota.user
[root@FQDN he]# setquota -u he 50M 60M 2000 2500 /home
setquota: user he does not exist.
[root@FQDN he]# cd home
-bash: cd: home: No such file or directory
[root@FQDN he]# ls
lost+found
[root@FQDN he]# cd ..
[root@FQDN /]# ls home
aquota.group aquota.user lost+found
[root@FQDN /]# setquota -u he 50M 60M 2000 2500 /home //设置用户的文件限额,设置为容量软限制50MB,硬限制60MB;文件次数软限制2000,硬限制2500
setquota: user he does not exist.
[root@FQDN /]# su - root
Last login: Thu Jan 11 21:44:03 CST 2018 on pts/1
[root@FQDN ~]# setquota -u he 50M 60M 2000 2500 /home
setquota: user he does not exist.
[root@FQDN ~]# useradd he
[root@FQDN ~]# setquota -u he 50M 60M 2000 2500 /home
[root@FQDN ~]# quota -u he
Disk quotas for user he (uid 1002):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/data-home
28 51200 61440 7 2000 2500
[root@FQDN ~]# setquota -u he 50M 60M 0 0 /home
[root@FQDN ~]# useradd he1
[root@FQDN ~]# setquota -u -p he he1 /home //以其他文件为参考设置用户的文件限额
[root@FQDN ~]# quota -u he1
Disk quotas for user he1 (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/data-home
28 51200 61440 7 0 0
[root@FQDN ~]# groupadd long
[root@FQDN ~]# groupadd long1
[root@FQDN ~]# setquota -g 1G 2G 20K 25K /home //设置组的磁盘限额,具体同上
setquota: group 1G does not exist.
[root@FQDN ~
942f
]# vi /etc/fstab
[root@FQDN ~]# setquota -g long 1G 2G 2k 25k /home //以其他组为参考设置组的磁盘限额
[root@FQDN ~]# quota -gv long
Disk quotas for group long (gid 1005):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/data-home
0 1048576 2097152 0 2000 25000
[root@FQDN ~]# setquota -g -p long long1 /home
[root@FQDN ~]# vi /etc/fstab
[root@FQDN ~]# quota -gv long1
Disk quotas for group long1 (gid 1006):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/data-home
0 1048576 2097152 0 2000 25000
[root@FQDN ~]# repquota –augv //查看磁盘限额报告
*** Report for user quotas on device /dev/mapper/data-home
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
he -- 28 51200 61440 7 0 0
he1 -- 28 51200 61440 7 0 0

Statistics:
Total blocks: 7
Data blocks: 1
Entries: 3
Used average: 3.000000
*** Report for group quotas on device /dev/mapper/data-home
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
Group used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 20 0 0 2 0 0
he -- 28 0 0 7 0 0
he1 -- 28 0 0 7 0 0
long -- 0 1048576 2097152 0 2000 25000
long1 -- 0 1048576 2097152 0 2000 25000

Statistics:
Total blocks: 7
Data blocks: 1
Entries: 5
Used average: 5.000000
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐