📄 067-070.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Configuration and Installation:Installing Linux</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=1558285660//-->
<!--TITLE=Linux Configuration and Installation//-->
<!--AUTHOR=Patrick Volkerding//-->
<!--AUTHOR=Kevin Reichard//-->
<!--AUTHOR=Eric Foster//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=2//-->
<!--PAGES=067-070//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="065-067.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="070-074.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>Linux and a Swap Disk</B></FONT></P>
<P>If you are using a PC with 4 megabytes of RAM, you may want to set up a <I>swap partition</I>. This partition is treated by the system as extended RAM; if you run low on memory (and with 4 megabytes of RAM, you’re guaranteed to), Linux can treat this hard disk section as RAM, or <I>virtual memory</I>. You’ll take a performance hit, as a hard disk will always be slower than real RAM, and you’ll have the joy of watching your hard disk churn furiously when you try to use a few applications. However, a swap partition can be used <I>only</I> for swap space by Linux; it can’t be used for any other storage. Therefore, you need to weigh your RAM needs versus your hard disk storage needs, keeping in mind that Linux should have as much hard disk territory for storage as possible.</P>
<P>You may also want to consider a swap partition if you have more than 4 megabytes of RAM. We’ve found that XFree86 is a little tight when running under only 8 megabytes of RAM, and some swap space can’t hurt, especially if you have a very large hard disk. (XFree86 won’t tell you that it’s low on RAM; it will simply refuse to do anything, such as failing to load an application.) Some Linux experts recommend that you have 16 megabytes of virtual memory. If you have only 8 megabytes of RAM, this would mean that you would want to set up at least an 8MB swap partition.</P>
<P>If you do want to create a swap partition, read on. If you don’t, you can skip to the next section, “Creating the Main Linux Partition.”</P>
<P>Your first move is to create a swap partition with the <B>fdisk</B> command. You’ll need to decide how large to make this partition. That will depend on how much free space you think you can give up on your hard drive. For the purposes of this chapter, we’ll devote 10 megabytes to swap space.</P>
<P>Run the <B>fdisk</B> command and choose the <B>n</B> option, for creating a new partition. You’ll see the following:</P>
<!-- CODE SNIP //-->
<PRE>
Command action
e extended
p primary partition (1-4)
</PRE>
<!-- END CODE SNIP //-->
<P>Type <B>p</B>, and enter the partition number. If you’ve already installed a DOS or OS/2 partition, you’ll need to select the number <B>2</B>, as partition number 1 is already is use:</P>
<!-- CODE SNIP //-->
<PRE>
Partition number (1-4): 2
</PRE>
<!-- END CODE SNIP //-->
<P>You’ll then be asked where to place the partition and how large to make it. Generally speaking, you’ll want to place the partition immediately after the previous partition:
</P>
<!-- CODE SNIP //-->
<PRE>
First cylinder (64-1010): 64
</PRE>
<!-- END CODE SNIP //-->
<P>Your numbers will undoubtedly be different. The point here is that <B>fdisk</B> automatically lists the first unassigned cylinder here (in this case, it was cylinder <I>64</I>), and you should go with that number.</P>
<P>You’ll then be asked how large you want to make the partition:</P>
<!-- CODE SNIP //-->
<PRE>
Last cylinder or +size or +sizeM or +sizeK (64-1010): +10M
</PRE>
<!-- END CODE SNIP //-->
<P>Because we’re not into figuring out how many cylinders or kilobytes it would take to make up 10 megabytes, we use the easy way out and specify 10 megabytes directly as <B>+10M</B>.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>This won’t apply to most users, but Linux doesn’t do very well if it’s installed as a boot partition on cylinder 1023 or above. (This occurs with very large hard drives—1 gigabyte or larger.) This has nothing to do with Linux, but rather with the limitations in the PC’s BIOS. Thus, you should avoid installing the Linux boot partition on a partition containing this cylinder or higher.<HR></FONT>
</BLOCKQUOTE>
<P><B>Fdisk</B> then creates the partition. To make sure that everything went correctly, type <B>p</B> to see a list of the current partitions:</P>
<!-- CODE SNIP //-->
<PRE>
Device Boot Begin Start End Blocks Id System
/dev/hda1 * 1 1 63 20762+ 4 DOS 16-bit (32M)
/dev/hda2 63 64 95 10560 83 Linux native
</PRE>
<!-- END CODE SNIP //-->
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>The number of blocks listed here will be handy when you actually make this partition a swap partition. Jot it down.<HR></FONT>
</BLOCKQUOTE>
<P><B>Fdisk</B> then gives you its command prompt; type <B>w</B> and exit.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>You may notice that the hard disk is pretty quiet when you’re making all these changes to the partition. The <B>fdisk</B> command doesn’t make its changes until you type the <B>w</B> command to exit. You can make all the changes you want and change your mind many times, but until you type <B>w</B>, it won’t matter.<HR></FONT>
</BLOCKQUOTE>
<P>You’ll then want to use the <B>mkswap</B> command to make the partition a swap partition. The command line is quite simple: You list the partition you want to make a swap partition (remembering that Linux lists partitions as <B>/dev/hda1</B>, <B>/dev/hda2</B>, and so on) and the size of the partition <I>in blocks</I>. The command line would look like the following:</P>
<!-- CODE SNIP //-->
<PRE>
# mkswap -c /dev/hda2 10560
</PRE>
<!-- END CODE SNIP //-->
<P>We told you the number of blocks would come in handy!
</P>
<P>The <I>-c</I> option checks for bad blocks on the partition. If <B>mkswap</B> returns any errors, you can ignore them, as Linux already knows of their existence and will ignore them.</P>
<P>After creating the swap partition, you’ll need to activate it with a command line like:</P>
<!-- CODE SNIP //-->
<PRE>
# swapon /dev/hda2
</PRE>
<!-- END CODE SNIP //-->
<P>Finally, you need to tell the filesystem that <B>/dev/hda2</B> is indeed a swap partition, again using the <B>fdisk</B> command. In this instance, you’ll need to change the <I>type</I> of the partition. When you created this partition, it was set up as a Linux native partition. However, Linux needs to explicitly know that this is a swap partition, so you need to change the type with the <B>t</B> command:</P>
<!-- CODE SNIP //-->
<PRE>
Partition number (1-4): 2
Hex code (type L to list codes): 82
</PRE>
<!-- END CODE SNIP //-->
<P>Linux supports a wide range of partition types, as you’d see if you typed <B>L</B>. However, you can take our word for it; <I>82</I> is the proper hex code. (You don’t need to know every single hex code; there’s little reason for you to know that <I>8</I> is the hex code for <I>AIX</I> or that <I>75</I> is the hex code for <I>PC/IX</I>.)</P>
<P>Quit <B>fdisk</B> using <B>w</B>, making sure that your changes are written to disk. It will take a few seconds for this to happen.</P>
<P>You’re now ready to create your main Linux partition.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="065-067.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="070-074.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -