配额实现

   1  启用配额限制 vim   /etc/fstab

     UUID=”5263027d-f571-4c4a-98d8-930e41e0e265″  /home  ext4  usrquota,grpquota  0 0

    [root@localhost ~]# mount -o remount  /home

     [root@localhost ~]# cd /home
     [root@localhost home]# ls
      fsy  lost+found  mage

   2创建配额数据库

  [root@localhost home]# mount

  [root@localhost home]# mount -o remount /home

 [root@localhost home]# mount

  /dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext=”system_u:object_r:tmpfs_t:s0″)
/dev/sda6 on /app type ext4 (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /home type ext4 (rw)
/dev/sdc1 on /home type ext4 (rw,usrquota,grpquota)      //  这一行必须生效
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

 

  [root@localhost ~]# getenforce 
Enforcing
[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce 

Permissive


[root@localhost home]# quotacheck -cug  /home         // c-create 创建的意思  u=user 用户 g=group用户组
[root@localhost home]# ls
aquota.group  aquota.user  fsy  lost+found  mage

[root@localhost home]# quotaon /home                 //  启用磁盘数据库

  

  

[root@localhost home]# edquota fsy                    //    设置 fsy用户

Disk quotas for user fsy (uid 500):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/sdc1                        32      80000     100000          8        0        0

   3 测试

[root@localhost home]# su fsy

[fsy@localhost home]$ cd /home/fsy
[fsy@localhost ~]$ touch f1

[fsy@localhost ~]$ dd if=/dev/zero of=f1 bs=1M  count=500 
sdc1: warning, user block quota exceeded.
sdc1: write failed, user block limit reached.
dd: writing `f1′: Disk quota exceeded
98+0 records in
97+0 records out
102367232 bytes (102 MB) copied, 0.216797 s, 472 MB/s

 

[fsy@localhost ~]$ dd if=/dev/zero of=f1 bs=1M  count=900
dd: writing `f1′: Disk quota exceeded
98+0 records in
97+0 records out
102367232 bytes (102 MB) copied, 1.10981 s, 92.2 MB/s

[fsy@localhost ~]$ dd if=/dev/zero of=f1 bs=1M  count=90
sdc1: warning, user block quota exceeded.
90+0 records in
90+0 records out
94371840 bytes (94 MB) copied, 0.411171 s, 230 MB/s

[fsy@localhost ~]$ ll f1 -h
-rw-rw-r–. 1 fsy fsy 90M Apr 25 17:40 f1

原创文章,作者:fsy,如若转载,请注明出处:http://www.178linux.com/74267

(0)
fsyfsy
上一篇 2017-04-25 22:30
下一篇 2017-04-26 14:28

相关推荐

  • 马哥教育网络班第19期+第7周课程练习

    1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; (2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; 2、创建一个大小为1G的swap分区,并创建好文件系统,并启用之; 3、写一个脚本  …

    Linux干货 2016-08-08
  • shell脚本编程之if条件判断与for、while、until循环

    一、if语句 语法: if 测试条件1 ; then        分支1 elif  测试条件2; then        分支2 … else&nbsp…

    Linux干货 2015-08-24
  • Linux 下的帮助及文件管理

    1、whatis     whatis command 或 man -f command     仅能提供命令基本的介绍。不提具体用法。     基于数据库的查找,优点:检索速度快;缺点:缺乏实时性    &n…

    2017-07-15
  • ssh+rsync批量管理,批量分发

    现在我简单架设了一个7台服务器的集群集体如下,架设集群的过程我就省略了… [nfs存储一台]192.168.42.10[负载均衡2台]192.168.42.40192.168.42.41[web服务器2台]192.168.42.30192.168.42.31[备份1台]192.168.42.20[mysql 1台]192.168.42.50 我现…

    Linux干货 2017-04-22
  • 救援SOS

    CentOS卸载内核后用救援模式恢复 1、卸载内核                              2、重启虚拟机后机器起不来,所以reboot重新启动立马按住ESC键,选择光盘引导 3、选择第三项&…

    Linux干货 2016-09-19
  • CentOS 7和CentOS 6 使用gpg工具实现公钥加密和解密

    运行环境: [root@Shining ~]# uname -a Linux Shining.ACG 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x…

    Linux干货 2016-12-01