📄 050-052.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Linux Installation Overview</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=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=2//-->
<!--PAGES=050-052//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="047-050.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="052-054.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading20"></A><FONT COLOR="#000077">Adding the Necessary Partition</FONT></H4>
<P>Because you’ve repartitioned the drive for DOS, you shouldn’t have to delete any partitions for Linux. You should only have to add partitions. To add a partition, issue the <TT>n</TT> command, which displays this:</P>
<!-- CODE SNIP //-->
<PRE>
Command Action
e extended
p primary(1-4)
</PRE>
<!-- END CODE SNIP //-->
<P>Press <p><Return>. <TT>fdisk</TT> then asks for the partition number; enter your selection and press <Return>. If you indicate a partition number already in use, <TT>fdisk</TT> reports this fact and asks you to delete the partition before trying to add it to the partition table. For this example, enter <TT>3</TT> to add a third primary partition that’s referred to as /dev/hda3.</P>
<P>Next, <TT>fdisk</TT> asks for the location of the first cylinder. This is usually the first available cylinder; in fact, <TT>fdisk</TT> displays a default range for your selection—for example:</P>
<!-- CODE SNIP //-->
<PRE>
First cylinder (42-1024) :
</PRE>
<!-- END CODE SNIP //-->
<P>Notice that the first partition ends at cylinder 41 and that the next partition begins at cylinder 1024. Thus, the range supplied by <TT>fdisk</TT> here allows you to start the next partition anywhere in the range of 42-1024. It’s a very good idea not to place partitions just anywhere throughout the disk; instead, choose the next available location, which in this case is cylinder 42. Enter <TT><B>42</B></TT> and press <Return>.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Linux can have trouble booting from partitions defined to start at cylinders above 1024. If you can create a Linux partition only in this range, you may have to boot Linux from a floppy. You learn how to create a boot floppy (different from the boot floppy used for installation) later in this chapter. The only downside is that it takes a little longer to boot Linux from a floppy than it does from the hard drive.<HR></FONT>
</BLOCKQUOTE>
<P>Now <TT>fdisk</TT> wants you to specify how much space to allocate for this partition. You can express this size in number of cylinders or by the number of bytes (<TT>+<I>size</I></TT>), kilobytes (<TT>+<I>size</I>K</TT>), or megabytes (<TT>+<I>size</I>M</TT>). Because you should already know the approximate size you need for the swap file, define this partition first, and then leave the rest of the disk space for the Linux program partitions. Thus, for this example, your machine has 8MB of RAM, so you need to specify a 16MB partition size by replying</P>
<!-- CODE SNIP //-->
<PRE>
Last cylinder or +size or +sizeM or +sizeK (42-1023): <B>+16M</B>
</PRE>
<!-- END CODE SNIP //-->
<P>You should then use the <TT>p</TT> command to look at the new partition table you’ve defined. In this example, the new partition table looks like</P>
<!-- CODE //-->
<PRE>
Disk /dev/hda: 15 heads, 17 sectors, 1024 cylinders
Units = cylinders of 255 * 512 bytes
Device Boot Begin Start End Blocks Id System
/dev/hda1 * 1 1 41 5219 1 DOS 12-bit FAT
/dev/hda2 1024 1024 4040 384667+ 51 Novell?
Partition 2 has different physical/logical endings:
phys=(967, 14, 17) Logical=(4039, 14.17)
/dev/hda3 42 42 170 16447+ 83 Linux native
</PRE>
<!-- END CODE //-->
<P>By default, <TT>fdisk</TT> made the new partition a Linux Native type. To change this to a swap partition, you need to use the <TT>t</TT> command. Enter <TT><B>t</B></TT>, and then enter the partition number you want to change; in this example, enter <TT><B>3</B></TT>. <TT>fdisk</TT> then requests that you enter the hexadecimal value of the desired partition type from Table 2.7 (if you don’t have the table handy, you can type <TT><B>l</B></TT> to get the list of codes). Because you want a swap partition, enter <TT><B>82</B></TT> at the prompt.</P>
<P>As you can see, <TT>fdisk</TT> reports the new partition type, but you can also use the <TT>p</TT> command to double-check that partition 3 is now a Linux swap partition.</P>
<P>Now you can add your Linux partitions. For this example, add only one partition, but if you want to have multiple partitions for various reasons, you can also do so at this time. To add a partition, press <n>, specify <TT>p</TT> for another primary partition, and then specify the number for this partition (4). To keep from fragmenting different partitions across the drive, start the last partition where the other left off, at cylinder 171. For the last cylinder, because you want to use the rest of the space for the Linux system, you can specify the last cylinder instead of an exact byte count. Thus, enter <B><TT>1023</TT></B>, as shown here:</P>
<!-- CODE SNIP //-->
<PRE>
Command (m for help):<B>n</B>
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): <B>4</B>
First cylinder (171-1024):<B>171</B>
Last cylinder or +size or +sizeM or +sizeK (171-1023):<B>1023</B>
</PRE>
<!-- END CODE SNIP //-->
<P>Now use the <TT>p</TT> command to verify the new partitions. If you need to make any changes, do so now.</P>
<P>When you’re satisfied with the layout of your partitions, you can use the <TT>w</TT> command to write the partition table information to the hard disk. None of your changes are permanent until you use the <TT>w</TT> command; thus, if you feel you’ve made some changes in error, you can use the <TT>q</TT> command to exit without altering the partition table. If you use the <TT>w</TT> command, Linux tells you the partition table has been altered and then resynchronizes the disks to match the new partition table. If your Linux system hangs at this point, reboot with the installation boot and root disks until you’re back at the <TT>#</TT> prompt.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CAUTION: </B><BR>Don’t use the Linux <TT>fdisk</TT> program to create or modify partitions for other operating systems. This could leave the hard drive in a useless state for both operating systems.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="047-050.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="052-054.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 + -