【Solaris】Solaris文件系统管理6 磁盘配额管理

Solaris文件系统管理6
磁盘配额管理



1 UFS文件系统磁盘配额使用

1.1 使文件系统支持配额功能

编辑/etc/vfstab文件,在/export/home 挂载选项增加rq标记
[root@solaris188:/]#cp /etc/vfstab /etc/vfstab.bak
[root@solaris188:/]#vi /etc/vfstab        
/dev/dsk/c0t0d0s7  /dev/rdsk/c0t0d0s7  /export/home  ufs  2  yes  rq
[root@solaris188:/]#cat /etc/vfstab | grep rq


重新挂载文件系统
[root@solaris188:/]#mount -o remount /export/home





1.2 在文件系统根目录建立配额文件

使用root用户,在/export/home下建立名为quotas的文件,该文件所有者为root,其他用户不能对它进行写操作。

[root@solaris188:/]#cd /export/home
[root@solaris188:/export/home]#touch quotas
[root@solaris188:/export/home]#chmod 600 quotas


1.3 对用户做配额限制
编辑tom用户配额项,使用i节点做限制
[root@solaris188:/]#edquota tom
fs /export/home blocks (soft = 0, hard = 0) inodes (soft = 10, hard = 15)


查看tom的配额限制
[root@solaris188:/]#quota -v tom


对文件系统开启配额功能      (关闭使用quotaoff)
[root@solaris188:/]#quotaon -av /export/home


同步文件系统配额,再次查看tom配额情况
[root@solaris188:/export/home]#quotacheck -av /export/home
[root@solaris188:/export/home]#quota -v tom

当前文件6,软限制10,硬限制15

1.4 tom用户创建新文件


[tom@solaris188:/export/home/tom]$touch file1
[tom@solaris188:/export/home/tom]$touch file2
[tom@solaris188:/export/home/tom]$touch file3



[root@solaris188:/]#quota -v tom


即将达到软限制,继续创建文件
[tom@solaris188:/export/home/tom]$touch file4

创建文件达到软限制时,会显示warning,但仍可以继续创建文件。

[root@solaris188:/]#quota -v tom

继续创建文件,达到应限制时报错,不能创建
[tom@solaris188:/export/home/tom]$touch file5
[tom@solaris188:/export/home/tom]$touch file6
[tom@solaris188:/export/home/tom]$touch file7
[tom@solaris188:/export/home/tom]$touch file8
[tom@solaris188:/export/home/tom]$touch file9



[root@solaris188:/]#quota -v tom


1.5 复制磁盘配额设置

将tom配置复制给bob
[root@solaris188:/]#edquota -p tom bob
[root@solaris188:/]#quota -v bob


查看文件系统上用户配额使用情况
[root@solaris188:/]#repquota -av


修改默认计时器 (不会影响当前的配额违反者)
[root@solaris188:/]#edquota -t
fs /export/home blocks time limit = 2 weeks, files time limit = 16 day

bob用户创建文件超过软限制
[bob@solaris188:/export/home/bob]$touch file1 file2 file3 file4 file5


[root@solaris188:/]#repquota -av


1.6 关闭磁盘配额
[root@solaris188:/]#quotaoff -av /export/home

删除配额文件
[root@solaris188:/export/home]#rm quotas


2 开启/关闭 ZFS磁盘配额

查看当前文件系统
[root@solaris188:/]#zfs list


查看磁盘配额属性
[root@solaris188:/]#zfs get quota


设置testpool/home/sandy配额为300m
[root@solaris188:/]#zfs set quota=300m testpool/home/sandy
[root@solaris188:/]#zfs list
[root@solaris188:/]#zfs get quota


取消对testpool/home/sandy的配额限制
[root@solaris188:/]#zfs set quota=none testpool/home/sandy
[root@solaris188:/]#zfs list
[root@solaris188:/]#zfs get quota







吕星昊
2016.1.8

?
请使用浏览器的分享功能分享到微信等