• 启动磁盘配额限制


    实现的功能:给用户增加磁盘限额为100M

    (1)启用配额功能:

    [root@www home07:11:21]# cat /etc/fstab    ##配置配额限制功能将/etc/fstab中加入usrquota,grpquota
    
    #
    # /etc/fstab
    # Created by anaconda on Sun Oct  2 22:20:50 2016
    #
    # 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=f15c3ecc-b6e0-4bba-8918-36b6fcac540f /                       ext4    defaults        1 1
    UUID=dcfcf26d-ae5e-4524-9326-c9cafffe7ecd /boot                   ext4    defaults        1 2
    UUID=98eefdc6-1f04-4784-8b31-876ee05e618f swap                    swap    defaults        0 0
    tmpfs                   /dev/shm                tmpfs   defaults        0 0
    devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
    sysfs                   /sys                    sysfs   defaults        0 0
    proc                    /proc                   proc    defaults        0 0
    /dev/sdb1 /newFS ext4  defaults 0 0
    /dev/sdc1 swap swap defaults 0 0 
    UUID=990eddeb-d162-4d6d-ac74-cdafa474e5c0  /home  ext4   usrquota,grpquota  0 0     ##userquota:增加用户配额限制;grpquota:增加用户组配额限制


    [root@www home07:10:51]#mount -o remount /home   ##启用配置
    [root@www home07:11:19]#mount            ##检查配置
    /dev/sda3 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/sda1 on /boot type ext4 (rw)
    /dev/sdb1 on /newFS type ext4 (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    /dev/sdd1 on /home type ext4 (rw,usrquota,grpquota)    ##配额功能已启用

    (2)创建配额数据库:在指定的分区下创建配额数据库,根据/etc/fstab指定的配额选项进行创建数据库

    [root@www home07:11:52]#quotacheck -cug /home # -c create 创建;-u userquote:用户的配额控制;-g grpquota:属组的配额控制;/home:要增加配额的分区(配额只能给分区)
    quotacheck: Cannot create new quotafile /home/aquota.user.new: Permission denied    ##拒绝的原因是SELinux,下面先关闭此功能
    quotacheck: Cannot initialize IO on new quotafile: Permission denied
    quotacheck: Cannot create new quotafile /home/aquota.group.new: Permission denied
    quotacheck: Cannot initialize IO on new quotafile: Permission denied
    [root@www home07:29:31]#getenforce   #查看SELinux状态 enforce执行
    Enforcing                 ##正在加强,正在执行保护
    [root@www home07:29:41]#setenforce  ##设置SELinux
    usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]    ##1为启用,0为关闭
    [root@www home07:32:36]#setenforce 0
    [root@www home07:32:40]#getenforce
    Permissive
    [root@www home07:32:47]#quotacheck -cug /home  ##创建磁盘配额数据库
    [root@www home07:40:49]#cd /home
    [root@www home07:41:32]#ls
    aquota.group  aquota.user  hadoop  lost+found  test  test1  wangcai  ##数据库已经在/home下创建成功
    [root@www home08:10:36]#quotaon -p /home      ##查看配额信息
    group quota on /home (/dev/sdd1) is off        
    user quota on /home (/dev/sdd1) is off
    [root@www home08:10:48]#quotaon /home        ##启用配额功能
    [root@www home08:11:06]#quotaon -p /home
    group quota on /home (/dev/sdd1) is on
    user quota on /home (/dev/sdd1) is on

    (3)给用户或者属组设置配额:指的是文件的所有者或者是所属组。

    [root@www home08:18:02]#edquota test1   ##给用户test1设置quota
    
    Disk quotas for user test1 (uid 501):
      Filesystem                   blocks      soft       hard     inodes     soft     hard
      /dev/sdd1                        20          0          0          5        0        0
    #blocks:单位KB,按块的大小进行磁盘配额设置,即可占用/home的空间大小;soft:警报值,用户test1占用空间达到此值时,警告,但仍可使用;hard:此时不能往磁盘写入任何数据
    #inodes:节点数,即文件个数;soft:用户test1所建的文件个数达到此值时,会警告,但仍可创建;hard:不可创建文件。
    #使用非交互的方式进行(默认单位是KB): setquota test1 1000 2000 1000 2000 /home
    [root@www home08:47:04]#useradd test2
    [root@www home08:50:27]#edquota -p test1 test2    ##quota权限的复制,复制给用户test2  
    [root@www home08:26:23]#edquota -g test1   #-g group :表示属组
    
    Disk quotas for group test1 (gid 501):
      Filesystem                   blocks       soft       hard     inodes     soft     hard
      /dev/sdd1                        20          0          0          5        0        0

    #grace :宽限期
  • 相关阅读:
    python正则表达式(+ {})(二)
    14丨 HTTP有哪些优点?又有哪些缺点?
    python正则表达式(. *)(一)
    12丨响应状态码该怎么用?
    Fiddler—Fiddler+willow插件应用(十四)
    11丨你能写出正确的网址吗?
    【洛谷P1858】多人背包
    【洛谷P3387】(模板)缩点
    【洛谷P2184】贪婪大陆
    Leetcode: 39. Combination Sum
  • 原文地址:https://www.cnblogs.com/wzhuo/p/6762553.html
Copyright © 2020-2023  润新知