solaris下quota机制对用户进行磁盘限额控制实践

文章作者 100test 发表时间 2007:10:10 11:47:54
来源 100Test.Com百考试题网


如何使用quota机制对用户进行磁盘限额控制

Solaris中的quota机制是一个很有用的管理机制,它可以使系统管理员对用户的磁盘使用限额进行有效地控制。可以控制的方式包括:限制用户占用磁盘总容量限制用户建立文件总数量限制某个文件系统中用户文件的存在时间

使用quota机制时,要在需限额的各文件系统之主目录下需事先建立quotas空文件(如无),然后使用edquota -v username命令修改指定用户在该文件系统下的限制份额(0=无限制,单位为k),或该用户在该文件系统下文件总个数限额。使用quotacheck命令使系统确认quotas中的新内容。最后使用quotaon命令使限额生效。检查quota的状态可以使用quota或repquota等命令。

前提:有多余的文件系统挂载或者对已经挂载的文件系统;本例是在ufs文件系统下实现。

下面举一示例进行说明。示例中对用户test在/export/home 文件系统中的磁盘限额进行控制:编辑/etc/vfstab文件:#device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # fd - /dev/fd fd - no - /proc - /proc proc - no - /dev/dsk/c0t0d0s1 - - swap - no - /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - /dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes rq swap - /tmp tmpfs - yes -

然后进入要限制的文件系统:# cd /export/home # touch quotas ;如果该文件已经存在则不需要# edquota test ;edquota将自动启动vi fs / blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)

~这里blocks是用户磁盘的限额,单位为k.soft是警告额度,hard是限制额度。

如果用户占用磁盘量超过警告额度,系统将在每次用户进行磁盘操作或登录时进行警告,要求用户减少磁盘占用量至软限制之下;如果用户的操作会导致超过hard限制,那么操作将失败。

inodes是用户文件数量,soft和hard的含义类似。

本例把该用户的限额改变为:警告限制=1024K,硬限制=1024K. fs / blocks (soft = 1024, hard = 1024) inodes (soft = 0, hard = 0)

~;别忘存盘退出# quotacheck -a ;通知系统确认新的quota # quotaon /export/home ;打开quota机制# repquota -v /export/home ;显示一下结果/dev/dsk/c0t0d0s0 (/):Block limits File limits User used soft hard timeleft used soft hard timeleft test —— 6 1024 1024 0 0 0

建立两个试验用的文件:# cd /tmp # mkfile 1000k a1000k # mkfile 1080k a1080k # chmod 666 a1000k # chmod 666 a1080k

# su - test Sun Microsystems Inc. SunOS 5.9 Generic May 2002 $ ls -l total 6 -rw-r——r—— 1 userq other 124 Mar 18 09:25 local.cshrc -rw-r——r—— 1 userq other 607 Mar 18 09:25 local.login -rw-r——r—— 1 userq other 582 Mar 18 09:25 local.profile $ cp /tmp/a1000k . $ cp /tmp/a1080k . quota_ufs: over hard disk limit (pid 1070, uid 1002, inum 371751, fs /)

cp: /tmp/a1080k: Disc quota exceeded

列目录看看,第二个cp操作因超过硬限额而失败。

$ ls -l total 2022 -rw-r——r—— 1 userq other 1024000 Mar 18 10:35 a1000k -rw-r——r—— 1 userq other 124 Mar 18 09:25 local.cshrc -rw-r——r—— 1 userq other 607 Mar 18 09:25 local.login -rw-r——r—— 1 userq other 582 Mar 18 09:25 local.profile $ exit

下面用edquota把test的硬限制改为2124后,再重复试验(别忘quotacheck!):

……

$ cp /tmp/a1080k . quota_ufs: Warning: over disk limit (pid 1151, uid 1002, inum 371751, fs /)

列目录看看,警告归警告,可是操作还是成功了。

$ ls -l total 4198 -rw-r——r—— 1 userq other 1024000 Mar 18 10:35 a1000k -rw-r——r—— 1 userq other 1105920 Mar 18 10:45 a1080k -rw-r——r—— 1 userq other 124 Mar 18 09:25 local.cshrc -rw-r——r—— 1 userq other 607 Mar 18 09:25 local.login -rw-r——r—— 1 userq other 582 Mar 18 09:25 local.profile $ exit



相关文章


Redhatadvanceserver2.1集群的安装与管理
如何在硬碟建置Linux系统之I tall实际安装
Linux系统学习方向和方法浅谈
ARCSolaris8安装完需要安装的数据包
solaris下quota机制对用户进行磁盘限额控制实践
linux下直接读写palm扩展卡内容
Linux告别低价“国情”神话认清TCO真相
为编程开发准备一台友好的CVS服务器
如何保存已满的SMF数据集中的内容
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛