📄 0420quota.htm
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
<meta name="Author" content="VBird, 鸟哥" >
<meta name="Description" content="让使用者能够使用的磁碟容量受限制!" >
<title>鸟哥的 Linux 私房菜 -- 磁碟配额 Quota</title>
<style type="text/css">
body {
background-color: #D3D3D3;
color: #000000;
background-attachment:fixed ;
}
body,th,td,input,select,textarea,select,checkbox {
font-family: '新细明体', 'Times New Roman', serif;
font-size: 11pt ;
}
a:link {text-decoration: none; color: blue}
a:visited {text-decoration: none; color: blue}
a:active {text-decoration: none; color: blue}
a:hover {text-decoration: underline; color: #ff0000}
table.head1 {width:100%; background-color: #FFCCCC;
border-style:groove;border-width:5px;border-color: #FFCCCC; margin:0;
padding: 5px 5px}
td.head1 {font: 10pt "新细明体", serif; color: #000099; }
td.info1 {font: 11pt "新细明体", serif; color: #000066; text-align:center; width:14%}
td.info2 {font: 11pt "新细明体", serif; color: #000066; text-align:center; width:12%}
*.info21 {font: 11pt "新细明体", serif; color: #000066; }
*.info22 {font: 11pt "新细明体", serif; color: blue ; }
*.info23 {font: 11pt "新细明体", serif; color: green ; }
td.info3 {font: 11pt "新细明体", serif; color: #000066; text-align:justify}
*.text_head0 {font-size:18pt; font-family:'标楷体','Times New Roman','Times', serif; }
*.text_head_en {font-size:18pt; font-family:'Times New Roman','Times', serif; }
*.text_h1 {font: 15pt "新细明体", serif; color: #0000BB; font-weight: bold }
*.text_h2 {font: 13pt "新细明体", serif; color: #0000BB; font-weight: bold }
*.text_import1 {font: 11pt "新细明体", serif; color: #000088; font-weight: bold }
*.text_import2 {font: 11pt "新细明体", serif; color: #000088; font-weight: normal}
*.text_vbird {font: 11pt "新细明体", serif; color: #000088; font-weight: normal;
font-style: italic;}
*.text_history {font: 10pt "新细明体", serif; color: #000066; }
*.text_date {font: 10pt "新细明体", serif; color: #3333FF; }
*.block1 {padding: 10px 20px 10px 25px; text-align:left }
*.block2 {padding: 10px 0px 10px 25px; text-align:left }
table.term2 {width: 350px; background-color: #000000;
border-style:groove;border-width:3px;border-color: #FFCCCC; margin:10px 0px;}
table.term {width: 580px; background-color: #000000;
border-style:groove;border-width:3px;border-color: #FFCCCC; margin:10px 0px;}
td.term {font: 10pt "细明体", Fixedsys, serif; color: #FFFFFF; }
*.term_hd {font: 10pt "细明体", Fixedsys, serif; color: #BBBBBB; }
*.term_note {font: 10pt "细明体", Fixedsys, serif; color: #777777; font-weight: normal }
*.term_note_b {font: 10pt "细明体", Fixedsys, serif; color: #FF77FF; font-weight: bolder }
*.term_command {font: 10pt "细明体", Fixedsys, serif; color: yellow ; font-weight: bolder }
*.term_write {font: 10pt "细明体", Fixedsys, serif; color: yellow ; font-weight: normal }
*.term_say {font: 10pt "细明体", Fixedsys, serif; color: #FF6666; font-weight: normal }
</style>
</head>
<body style="margin:0; padding:0">
<center>
<!-- 这里是关于页首按钮处的按钮程式 -->
<div style="text-align:center">
<span style="font-weight:bolder; color:#3333FF"><span class="text_head0">鸟哥的<span class="text_head_en">
Linux </span>私房菜</span></span><br />
<span style="color:#000080">为取得较佳浏览结果,请爱用 <a href="http://moztw.org" target="_blank">firefox</a>
浏览本网页</span><br />
<a href="http://linux.vbird.org/" target="_blank"
onmouseover="document.head_icon1.src='../images/icon_VBird_on.jpg'"
onfocus="document.head_icon1.src='../images/icon_VBird_on.jpg'"
onmouseout="document.head_icon1.src='../images/icon_VBird_off.jpg'">
<img alt="前往鸟哥的 Linux 私房菜馆首页" title="前往鸟哥的 Linux 私房菜馆首页" name="head_icon1"
src="../images/icon_VBird_off.jpg" border="0" /></a>
<a target="_blank" href="http://linux.vbird.org/linux_basic"
onmouseover="document.head_icon2.src='../images/icon_basic_on.jpg'"
onfocus="document.head_icon2.src='../images/icon_basic_on.jpg'"
onmouseout="document.head_icon2.src='../images/icon_basic_off.jpg'">
<img src="../images/icon_basic_off.jpg" border="0"
alt="前往 Linux 基础文件,新手请从头学起"
title="前往 Linux 基础文件,新手请从头学起" name="head_icon2" /></a>
<a target="_blank" href="http://linux.vbird.org/linux_server"
onmouseover="document.head_icon3.src='../images/icon_server_on.jpg'"
onfocus="document.head_icon3.src='../images/icon_server_on.jpg'"
onmouseout="document.head_icon3.src='../images/icon_server_off.jpg'">
<img src="../images/icon_server_off.jpg" border="0"
alt="前往 Linux 架站文件,网路基础那章节请务必参考!"
title="前往 Linux 架站文件,网路基础那章节请务必参考!" name="head_icon3" /></a>
<a target="_blank" href="http://linux.vbird.org/linux_security"
onmouseover="document.head_icon4.src='../images/icon_security_on.jpg'"
onfocus="document.head_icon4.src='../images/icon_security_on.jpg'"
onmouseout="document.head_icon4.src='../images/icon_security_off.jpg'">
<img src="../images/icon_security_off.jpg" border="0"
alt="前往『网路安全』相关文件网页" title="前往『网路安全』相关文件网页" name="head_icon4" /></a>
<a href="http://phorum.vbird.org" target="_blank"
onmouseover="document.head_icon5.src='../images/icon_forum_on.jpg'"
onfocus="document.head_icon5.src='../images/icon_forum_on.jpg'"
onmouseout="document.head_icon5.src='../images/icon_forum_off.jpg'">
<img src="../images/icon_forum_off.jpg" border="0"
alt="前往 Linux 新手讨论区,发问前务必查阅发文规则"
title="前往 Linux 新手讨论区,发问前务必查阅发文规则" name="head_icon5" /></a>
<a target="_blank" href="http://linux.vbird.org/adsl"
onmouseover="document.head_icon6.src='../images/icon_adsl_on.jpg'"
onfocus="document.head_icon6.src='../images/icon_adsl_on.jpg'"
onmouseout="document.head_icon6.src='../images/icon_adsl_off.jpg'">
<img src="../images/icon_adsl_off.jpg" border="0"
alt="前往『ADSL连线分享』相关文件网页" title="前往『ADSL连线分享』相关文件网页" name="head_icon6" /></a>
<a href="http://www.study-area.org" target="_blank"
onmouseover="document.head_icon7.src='../images/icon_study-area.jpg'"
onfocus="document.head_icon7.src='../images/icon_study-area.jpg'"
onmouseout="document.head_icon7.src='../images/icon_study-area.jpg'">
<img src="../images/icon_study-area.jpg" border="0"
alt="前往 Study Area 网站" title="前往 Study Area 网站" name="head_icon7" /></a>
<br />
</div>
<table summary="本文内容的排版" style="width:750px;
background-image:url('../images/VBirdLinux.jpg');
background-attachment:fixed;" border="0" cellspacing="0" cellpadding="0">
<tr><td style="width:16px; height:16px; background-image:url('../images/border-top-left.jpg');
font-size:6px"> </td>
<td style="width:718px; height:16px; font-size:6px;
background-image:url('../images/border-top-center.jpg')"> </td>
<td style="width:16px; height:16px; background-image:url('../images/border-top-right.jpg');
font-size:6px"> </td></tr>
<tr><td style="width:16px; font-size:6px;
background-image:url('../images/border-middle-left.jpg')"> </td>
<td width="718">
<!-- 本文的档头部分 -->
<div style="text-align:center">
<a href="0420quota.php">
<span class="text_head0"><span class="text_head_en">Linux </span>磁碟配额 (Quota)</span></a><br />
</div>
<div style="text-align:left">
<a href="0420quota.php?thisscreen=800x600"><!--切换解析度为 800x600--></a>
</div>
<div style="text-align:right">
<span class="text_history">最近更新日期∶2005/09/06</span>
</div>
<!-- 本文的档头部分 -->
<table class="head1" summary="排版∶文章档头的说明"><tr><td class="head1">
磁碟配额 ( Quota ) 一直就是个很有用的东西!怎么说呢?举个例子来说明,
如果您曾经申请过网路的 mail 服务时,那么肯定就会明白什么是 20MB 的邮件空间、
30MB 的免费网页空间,好了,这个 20MB, 30MB 是怎样定义出来的呢?哈哈!没错,就是
quota 这个东西搞出来的!如果我们要限制使用者使用硬碟的容量使用大小,嗯!来这里看看就对了!
</td></tr></table><br>
<!-- 本文的连结区部分 -->
<div class=block1>
<span class="text_h1">
1. <a href="#whatis">什么是 quota</a><br>
2. <a href="#quota_command">基本的 quota 指令介绍∶</a><br>
<span class=text_h2>
<a href="#mtab">/etc/mtab</a>, <a href="#quota">quota</a>,
<a href="#quotacheck">quotacheck</a>, <a href="#edquota">edquota</a>,
<a href="#quotaon">quotaon</a>, <a href="#quotaoff">quotaoff</a><br>
</span>
3. <a href="#manual">实作 quota</a><br>
4. <a href="#nochange">不更动既有系统的 quota 实例</a><br>
5. <a href="#FAQ">本章习题练习</a><br>
<span class=text_h2>
6. <a href="http://phorum.vbird.org/viewtopic.php?t=23888"
target="_blank">针对本文的建议∶http://phorum.vbird.org/viewtopic.php?t=23888</a>
</span>
</span>
</div>
<!-- 本文的正式部分 -->
<hr><a NAME="whatis"></a><img src="images/penguin-m.gif" alt="大标题的图示" height="34" width="25" align="middle" /><span class="text_h1">什么是 Quota</span><br>
<div class=block1>
『 quota 』就字面上的意思来看,呵呵!就是有多少『限额』的意思啦!如果是用在零用钱上面,
就是类似『<span class=text_import2>有多少零用钱一个月</span>』的意思之类的。如果是在容量空间上面呢?以
Linux 来说,呵呵!就是有多少容量限制的意思。<br><br>
在 Linux 系统中,由于是多人多工的环境,所以会有多人共同使用一个硬碟空间的情况发生,
如果其中有少数几个使用者大量的占掉了硬碟空间的话,那势必压缩其他使用者的使用权力!
因此管理员应该适当的开放硬碟的权限给使用者,以妥善的分配系统资源!避免有人抗议呀!
举例来说,我们使用者的预设家目录都是在 /home 底下,如果 /home 是个独立的 partition ,
他大概有 10G 好了,而 /home 底下共有 30 个人,也就是说,每个使用者平均应该会有 333MB 的空间才对。
偏偏有个使用者在他的家目录底下塞了好多苹影片,占掉了 8GB 的空间,想想看,是否造成其他正常使用者的不便呢?
这个时候就得要靠 quota 的帮忙棉!<br><br>
<li><span class=text_import1>Quota 的一般用途</span></li>
<div class=block2>
quota 比较常使用的几个情况是∶<ul><span class=text_import2>
<li>针对 WWW server ,例如∶每个人的网页空间的容量限制!
<li>针对 mail server,例如∶每个人的邮件空间限制。
<li>针对 file server,例如∶每个人最大的可用网路硬碟空间。</ul></span>
在 Linux 当中,使用来作为硬碟空间管理的就是所谓的 quota 这个咚咚啦!<br><br>
</div>
<li><span class=text_import1>Quota 的使用限制</span></li>
<div class=block2>
使用这个模组要有几个步骤,底下就分别说说吧!另外要特别注意的是,使用
quota 时有几个基本的限制需要谈一谈∶<ul>
<li><span class=text_import2>仅针对整个 partition∶</span><br>
quota 实际在运作的时候,是针对『<span class=text_import2>整个 partition</span>』进行限制的,
例如∶如果你的 /dev/hda5 是挂载在 /home 底下,那么在 /home 底下的所有目录都会受到限制!</li><br>
<li><span class=text_import2>核心必须支援 quota ∶</span><br>
Linux 系统核心必须有支援 quota 这个模组才行∶如果您是使用 FC4 的预设核心,
嘿嘿!那恭喜你了,你的系统已经预设有开放
quota 这个模组棉!如果您是自行编译核心的,那么请特别留意您是否已经『真的』开启了
quota 这个模组?否则底下的功夫将全部都视为『白工』。至于核心编译的过程我们会在未来进行说明呦!</li><br>
<li><span class=text_import2>Quota 的记录档∶</span><br>
目前新版的 Linux distributions 如∶ FC4 与 SuSE server 9 等使用的是
Kernel 2.6.xx 的核心版本,这个核心版本支援新的 quota 模组,使用的预设档案(
aquota.user, aquota.group )将不同于旧版本的 quota.user, quota.group !(多了一个
a 呦!)而由旧版本的 quota 可以藉由 convertquota 这个程式来转换呢!</li><br>
<li><span class=text_import2>只对一般身份使用者有效∶</span><br>
这就有趣了!并不是所有在 Linux 上面的帐号都可以设定 quota 呢,例如 root 就不能设定 quota ,
因为整个系统所有的资料几乎都是他的啊! ^_^</ul>
</DIV>
<li><span class=text_import1>quota 这支程式对硬碟配额的限制项目∶</span></li>
<div class=block2>
quota 这支程式针对整个 partition 的限制项目主要分为底下几个部分∶
<ul>
<li><span class=text_import2>soft</span>∶<br>
这是最低限制容量的意思,使用者在宽限期间之内,他的容量可以超过
soft ,但必需要宽限时间之内将磁碟容量降低到 soft 的容量限制之下!</li><br>
<li><span class=text_import2>hard</span>∶<br>
这是『绝对不能超过』的容量!跟 soft
相比的意思为何呢?通常 hard limit 会比 soft limit 为高,例如网路磁碟空间为
30 MB ,那么 hard limit 就设定为 30MB ,但是为了让使用者有一定的警戒心,所以当使用空间超过
25 MB 时,例如使用者使用了 27 MB 的空间时,那么系统就会警告使用者,
让使用者可以在『宽限时间内』将他的档案量降低至
25 MB ( 亦即是 soft limit )之内!也就是说, soft 到 hard
之间的容量其实就是宽限的容量啦!可以达到针对使用者的『警示』作用!</li><br>
<li><span class=text_import2>宽限时间</span>∶<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -