Linux学习笔记:磁盘配额(Quota)与高级文件系统管理


磁盘配额(Quota)与高级文件系统管理

Table of Contents

1 磁盘配额(Quota)的应用与实例

2 软件磁盘阵列(RAID)

3 逻辑卷管理员(Logic Volume Manager)

1 磁盘配额(Quota)的应用与实例

什么是磁盘配额 : Linux 是多用户系统,磁盘配额是分配给每个用户的磁盘可用空间的限制。

如何建立磁盘配额

制作账号环境

# !/bin/bash
# Program:
# This program is used to create account environment for "quota"
# History:
# 2013/2/5 on_1y First release

PATH=$PATH
export PATH

# create a group,put the accounts which is need to be "quota" in it
groupadd myquotagrp
for username in minix01 minix02 minix03
do
    useradd -g myquotagrp $username
    echo "password:" | passwd --stdin $username
done

exit 0

查看文件系统是否支持

$ df -h /home
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda10      94G  37G  53G  41% /home
$ mount | grep home
/dev/sda10 on /home type ext4 (rw)

注意不能对目录进入磁盘配额,要对文件系统,所以如果想对home进行磁盘配额,home 需要是一个独立的文件系统,如果不是,那么只能对/进行磁盘配额

另外,VFAT文件系统不支持磁盘配额,所以还需要用mount查看一下文件系统类型

增加quota支持 在/etc/fstab中的/home段的default后增加两个参数 /home          ext4    defaults,usrquota,grpquota
然后重新挂载/home

# umount /home
# mount -a
# mount | grep home
# /dev/sda10 on /home type ext4 (rw,usrquota,grpquota)
扫描文件系统并建立Quota记录文件
quotacheck -avug
-a:扫描所有/etc/mtab内,含quota支持的文件系统
-v:显示扫描过程信息
-u:建立aquota.user,会出现在/home下
-g:建立aquota.group,会出现在/home下
Quota的启动,关闭与限制设定
启动
quotaon -avug
-a:启动/etc/mtab下所有支持quota文件系统,-v:显示启动过程信息
-u:启动用户限制,-g:启动群组限制
关闭
quotaoff
设定用户配额
edquota # edquota -u minix01
Disk quotas for user minix01 (uid 701)
Filesystem blocks soft hard inodes soft hard
/dev/sda10  80    0    0    10    0
blocks:磁盘容量
soft/hard:超过soft值会提醒,超过hard值会锁磁盘,单位KB,为0表示无限制
indoes:档案数
soft/hard:inodes的soft/hard
复制给其它账号
edquota -p minix01 -u minix02
设定组配额
edquota -g myquotagrp
Quota值的显示
quota -uvs minix01 minix02
显示用户配额
-u:后面指定用户名
-v:显示每个用户在文件系统中quota值
-s:使用1024倍数显示大小单位
repquota -auvs
显示文件系统配额

  • 1
  • 2
  • 下一页

相关内容