quota设置

***磁盘配额
ext系列文件系统的quota

    1.开启quota(ext、xfs)
    vim /etc/fstab
    在需要开启quota的文件系统的挂载选项的defaults后加usrquota,grpquota如下
    /dev/sda5  /app                    ext4    defaults,usrquota,grpquota        1 0

需卸载硬盘,然后重新挂载到指定的目录下

如果出现权限报错,设置selinux为0,既setenforce=0

    2.生成quota数据库
    quotacheck -cugm /app/

    3.开启quota
    quotaon /app

    quota 
        -v 显示当前用户自己的quota限额
        -v username 显示指定用户的quota限额 仅限root


    repquota -v /app 显示所有用户的quota限额(仅限用户在该目录有所属的文件) 仅限root


    4.配置quota
    edquota -u/g username/groupname
        edquota -u liubei
        edquota -g shuguo

    或非交互式
    setquota -u[default] |-g  username|groupname 10M 20M 5 20 /app
        setquota -u liubei 0 0 0 0 /app 
        setquota -g shuguo 10M 20M 50 100 /app

    edquota -p liubei zhangfei  将liubei的quota设置复制给zhangfei


    注意:对group设置quota时,应该对附加组设置,同时,目录要设置sgid权限才有意义 

xfs文件系统的quota
    1.开启quota(ext、xfs)
    vim /etc/fstab
    在需要开启quota的文件系统的挂载选项的defaults后加usrquota,grpquota如下
    /dev/sda5  /app                    ext4    defaults,usrquota,grpquota        1 0

    一定要卸载再挂载才生效


    2.配置
    xfs_quota -x -c "print" 查看当前系统中所有的xfs文件系统哪些开启了quota
        Filesystem          Pathname
        /                   /dev/sda2
        /boot               /dev/sda1
        /app                /dev/sda3 (uquota, gquota)    

    xfs_quota -x -c "report -ugibh"  查看quota设置
        -u 查看用户的
        -g 查看组的
        -i 查看inode
        -b 查看block (默认)
        -h human-readable
        默认是-ug
        ***-uibh
    xfs_quota -x -c "state" /app 查看qutoa状态,显示grace time时间

    xfs_quota -x -c "limit -u bsoft=30M bhard=40M liubei" /app
    对用户设置quota
    xfs_quota -x -c "limit -g bsoft=50M bhard=100M shuguo" /app
    对组设置quota
    xfs_quota -x -c "timer -u -b 14days" /app
    设置quota grace time

    获取帮助
    xfs_quota -x -c "help limit"
    xfs_quota -x -c "help report"

猜你喜欢

转载自blog.csdn.net/qq_34208467/article/details/82151844