⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node61.html

📁 Linux帮助文档之系统管理员手册
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<html>
<head>
<title>产生对换空间</title>
<meta NAME="description" CONTENT="Creating a swap space">
<meta NAME="keywords" CONTENT="sag">
<meta NAME="resource-type" CONTENT="document">
<meta NAME="distribution" CONTENT="global">
<link REL="STYLESHEET" HREF="sag.css">
</head>
<body LANG="EN">
 <a NAME="tex2html1062" HREF="node62.html"><img WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" ALT="next" SRC="./next_motif.gif"></a> <a NAME="tex2html1060" HREF="node59.html"><img WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" ALT="up" SRC="./up_motif.gif"></a> <a NAME="tex2html1054" HREF="node60.html"><img WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" ALT="previous" SRC="./previous_motif.gif"></a> <a NAME="tex2html1064" HREF="node1.html"><img WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" ALT="contents" SRC="./contents_motif.gif"></a> <a NAME="tex2html1065" HREF="node108.html"><img WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" ALT="index" SRC="./index_motif.gif"></a> <br>
<b> Next:</b> <a NAME="tex2html1063" HREF="node62.html">Using a swap space</a>
<b>Up:</b> <a NAME="tex2html1061" HREF="node59.html">Memory Management</a>
<b> Previous:</b> <a NAME="tex2html1055" HREF="node60.html">What is virtual memory?</a>
<br> <p>
<h1><a NAME="SECTION00620000000000000000">产生对换空间</a></h1>
<p>
对换文件是普通文件,对核心没有什么特别的。唯一不同是它没有孔,用
<tt>mkswap</tt><a NAME="1890">&nbsp;</a>准备。必须在本地盘上,不能
在通过NFS mount的文件系统中。
<p>
关于孔,是重要的。对换文件保留了磁盘空间,使核心能快速对换出一页,而不必经过如文件的定位磁盘扇区的全部事情。
核心只用分配给这个文件的所有扇区。由于文件中的孔意味着没有为文件中这个位置分配磁盘扇区,这对核心使用不利。
<p>
产生没有孔的对换文件的一个好办法是通过如下命令:
		<blockquote> <tt>
<code>$</code> <i>dd if=/dev/zero of=/extra-swap bs=1024 count=1024</i><br> 
<code>1024+0 records in</code> <br> 
<code>1024+0 records out</code> <br> 
<code>$</code>
		</tt></blockquote>
<tt>/extra-swap</tt><a NAME="1892">&nbsp;</a>是对换文件名,大小由<tt>count=</tt>给出. 
大小最好是4的倍数,因为核心写出的<b>内存页</b>是4KB。如果不是4的倍数,最后那几KB将不可用。
<p>
对换分区也没什么特别。就象产生其他分区一样产生;唯一的不同是它作为原始分区使用,即没有任何
文件系统,最好将对换分区标记为类型82(Linux swap),虽然这对核心没有影响,但这使分区列表更清晰。
<p>
产生对换文件或对换分区后,需要写个标记起用它,这包括核心要用的一些管理信息。命令是
<tt>mkswap</tt><a NAME="1895">&nbsp;</a>, 用法如下:
		<blockquote> <tt>
<code>$</code> <i>mkswap /extra-swap 1024</i> <br> 
<code>Setting up swapspace, size = 1044480 bytes</code> <br> 
<code>$</code>
		</tt></blockquote>
注意对换空间现在还没用,它存在,但核心还没用它提供虚拟内存。
<p>
请一定小心使用<tt>mkswap</tt><a NAME="1897">&nbsp;</a>, 因为它不检查文件或分区是否被其他东西使用。
<em>你可能用<tt>mkswap</tt><a NAME="1899">&nbsp;</a>很容易地覆盖了重要文件和分区!</em>
幸好,你只需在你安装系统时使用<tt>mkswap</tt><a NAME="1901">&nbsp;</a>。
<p>
Linux内存管理限制了每个对换空间约为127MB(由于技术原因,实际限制是
<img WIDTH="251" HEIGHT="24" ALIGN="MIDDLE" ALT="tex2html_wrap_inline3833" SRC="img11.gif">字节,
或127.6875MB)。 可以同时使用最多16个对换空间,总计差不多2GB。
<a NAME="tex2html26" HREF="footnode.html#1835">
<img ALIGN="BOTTOM" ALT="gif" SRC="./foot_motif.gif" WIDTH="15" HEIGHT="15"></a>
<p>
<hr><a NAME="tex2html1062" HREF="node62.html"><img WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" ALT="next" SRC="./next_motif.gif"></a> <a NAME="tex2html1060" HREF="node59.html"><img WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" ALT="up" SRC="./up_motif.gif"></a> <a NAME="tex2html1054" HREF="node60.html"><img WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" ALT="previous" SRC="./previous_motif.gif"></a> <a NAME="tex2html1064" HREF="node1.html"><img WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" ALT="contents" SRC="./contents_motif.gif"></a> <a NAME="tex2html1065" HREF="node108.html"><img WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" ALT="index" SRC="./index_motif.gif"></a> <br>
<b> Next:</b> <a NAME="tex2html1063" HREF="node62.html">Using a swap space</a>
<b>Up:</b> <a NAME="tex2html1061" HREF="node59.html">Memory Management</a>
<b> Previous:</b> <a NAME="tex2html1055" HREF="node60.html">What is virtual memory?</a>
<p><address>
<i>Lars Wirzenius <br>
Sun Jun 29 13:31:22 EEST 1997</i>
</address>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -