Quota简介
在Linux系统中,因为是多人的工做环境,因此会有不少人共同使用相同磁盘空间的状况发生。为避免磁盘使用不当,管理员应该适当限制磁盘的容量给使用者,以妥善的分配系统资源。Quota正是一个配置磁盘限额的工具。
Quota的规范设定项目
- 使用者、群组、目录 :XFS文件系统的quota限制中,主要是针对群组、我的或单独的目录进行磁盘使用率的限制。
- 容量、数量 :限制inode或block用量。
- 柔性、硬性 :限制soft和hard,一般hard的限制值比soft的限制值要高。
Quota查看命令
xfs_quota -x -c "指令" 挂载点
- -x :专家模式,后续才能加入-c的指定参数
- -c :后面加指令
$ xfs_quota -x -c "state"
$ xfs_quota -x -c "report" /home
$ xfs_quota -x -c "df -h" /home
$ xfs_quota -x -c "print"
$ xfs_quota -x -c "report -ugibh" /home
$ xfs_quota -x -c "report -pbih" /home
注:
u > 用户user
g > 组group
i > inode限制数量
b > block限制大小
h > 人性化human
p > 对象proj
Quota内部指令
若是须要暂停使用quota限制或者从新启动quota时,可经过如下命令实现。另外,已经设置好的策略,不能单条删除,只能所有抹去再从新配置。
- disable :暂时取消quota的限制,但其实系统仍是在计算quota中,只是没有管制而已。
- enable :恢复到正常管制的状态,与disable相互取消、启用。
- off :彻底关闭quota的限制,使用了这个状态后,只有卸载再从新挂载才能再次启动quota。
- remove :必需要在off的状态下才能执行的指令~这个remove能够能够“移除”quota的限制设置。只要remove -p就能够了!
$ xfs_quota -x -c "disable -up" /home/
$ xfs_quota -x -c "state" /home/
$ xfs_quota -x -c "enable -up" /home/
$ xfs_quota -x -c "off -up" /home/
$ xfs_quota -x -c "state" /home/
$ xfs_quota -x -c "remove -p" /home/
$ xfs_quota -x -c "report -pibh" /home/
Quota配置prjquota
projquota不能与grpquota同时配置。针对目录的设置须要指定一个所谓的
专案名称、专案识别码来规范才行,并且还须要用到两个设定档。其中,专案名称和识别码本身随意设定就能够。
$ echo "1:xiangyu.liu" >> /etc/projects
$ echo "xiangyu.liu:1" >> /etc/projid
$ xfs_quota -x -c "project -s xiangyu.liu" #初始化专案名称
$ xfs_quota -x -c "report -pbih" /home
$ xfs_quota -x -c "limit -p bsoft=450M bhard=500M xiangyu.liu" /home #设置
$ xfs_quota -x -c "report -pbih" /home
$ dd if=/dev/zero of=/home/users/xiangyu.liu/test.img bs=1M count=510 #测试
Quota注意事项
- 针对须要配置的磁盘,查看文件系统、挂载目录、磁盘空间;
- /etc/fstab自动挂载的配置,示例:UUID=** /home xfs usrquota,grpquota,prjquota,defaults 0 0
- 若是须要格式化磁盘,注意磁盘UUID的变化并及时更新/etc/fstab的配置;不然Linux系统会启动报错。
2019/4/16