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

📄 linux-partition.html

📁 Linus guide, Linus guide, Linus guide,
💻 HTML
📖 第 1 页 / 共 3 页
字号:
			don't do something. </FONT>			</P>			<P ALIGN=LEFT><FONT SIZE=4>This is another excellent part of the			directory tree to place on its own partition.</FONT></P>			<UL>				<LI><P ALIGN=LEFT><FONT SIZE=4><A HREF="file:/var">Click				here to see your own /var directory</A> </FONT>				</P>				<LI><P ALIGN=LEFT><FONT SIZE=4><A HREF="file:/var/log">Click				here to see /var/log directory</A> </FONT>				</P>				<LI><P ALIGN=LEFT><FONT SIZE=4><A HREF="file:/var/log/messages">Click				here to see your ALL IMPORTANT /var/log/messages file</A> </FONT>				</P>				<LI><P ALIGN=LEFT><FONT SIZE=4><A HREF="file:/var/spool/mail">Click				here to see where Linux stores incoming Email</A> </FONT>				</P>				<LI><P ALIGN=LEFT><FONT SIZE=4><A HREF="file:/var/spool/mqueue">Click				here to see where Linux stores outgoing Email</A> </FONT>				</P>			</UL>		</TD>	</TR>	<TR>		<TD WIDTH=16%>			<P><BR>			</P>		</TD>		<TD WIDTH=84% VALIGN=TOP></TD>	</TR>	<TR>		<TD WIDTH=16% VALIGN=TOP>			<P><TT><B>/tmp</B></TT></P>		</TD>		<TD WIDTH=84% BGCOLOR="#e2e2e2">			<P ALIGN=LEFT><FONT SIZE=4>This place is for programs' temporary			files. </FONT>			</P>			<P ALIGN=LEFT><FONT SIZE=4>Poorly behaved or crashing programs			will leave turds here, and /tmp will fill up eventually just like			/var.</FONT></P>		</TD>	</TR></TABLE></BLOCKQUOTE></FONT><P><BR><BR><BR><BR></P><H2>Summary</H2><P><BR><BR></P><UL><LI><P>Computers can have many hard disk drives</P><P><BR></P><LI><P>Each hard drive can have one or more logical partitions</P><P><BR></P><LI><P>Linux will need at least TWO partitions, one for swap space andone for the file system</P><P><BR></P><LI><P>Unix file systems are made up of a Directory Tree</P><P><BR></P><LI><P>Each directory, starting with the root directory, can be a MountPoint for a partition. In other words, /home/allen can represent awhole partition, and /var/logs can be on another partition, etc.,etc., and these partitions can be on any of the hard drives in thesystem. Which is why on Unix you don't see drive identifiers like onDOS and Windows &quot;C:\&quot;.</P><P><BR></P><LI><P>Some parts of the Linux directory tree are known to be good thingsto stick on their own partitions, including /var, /tmp, /home...</P><P><BR></P><LI><P>Hard drives have names that are represented in the /dev directory.IDE Drives look like /dev/hda, /dev/hdb; and SCSI drives look like/dev/sda, and /dev/sdb.</P><P><BR></P><LI><P>Partitions on disk drives are named with the device and then thepartition's number, thus: /dev/hda1, /dev/hda2, etc., on IDE drives,and /dev/sda1, /dev/sda2, etc., etc., on SCSI drives.</P><P><BR></P><LI><P>Mapping a Partition into the Directory Tree requires that you knowthe name of the partition, like &quot;/dev/sda5&quot;, and theDirectory Path under which the partition is to be mounted, like&quot;/home/allen/lots_of_stuff&quot;</P><P><BR></P><LI><P>No particular part of the directory tree needs to be on anyspecific partition. The sky is the limit.</P><LI><P>Partitions, must be big enough to allow for all of the files theymust contain initially, plus room for growth where appropriate. Forexample, if and when you rebuild the Linux kernel from source, therehad better be enough room for the compiler to run and generate outputon whatever partition &quot;/usr/src&quot; is mounted. Not only that,there had better be room in &quot;/boot&quot;, if it is mounted on aseparate partition, for the new kernel image !</P><P><BR></P><LI><P>Mounting and un-mounting a floppy disk or CD-ROM is synonymouswith mounting and un-mounting a hard disk partition - except in theformer cases they are &quot;Removable Media&quot;, whereas, hard diskdrives normally don't come out without a lot of effort. </P></UL><P><BR><BR></P><P><BR><BR></P><H2>Aha! &nbsp;And I have Windows !</H2><P><BR><BR></P><BLOCKQUOTE><P>If you want to have more than one operating system installed onthe same set of hard disk drives in one computer, you'll need toremember that hard disk partitions have a TYPE.&nbsp;&nbsp;</p><p>This TYPE is an integer value that identifies the category of file system expected tobe Formatted onto that partition.</p><p>For example, you might have threepartitions, one for Windows with a TYPE DOS-32, and two for Linux,TYPED Linux-Swap and Linux-Native.</P><p>The way that YOU will be identifying the TYPES will be by the integer values if you are using fdisk,or by the Named Types like I've listed here if you're using Disk Druid - of course Disk Druid is just being friendly and will actually use the associated integer value, I believe ranging from 0-255.</p><p>Fdisk is friendly in a different way, using it's help for partition types, you can see a list ofpartition types and their associated integer values, and you'll have to remember that and type it inas you're creating a partition.</p><P></P><P><b>ANY PARTITION MUST BE FORMATTED BEFORE AN OPERATING SYSTEM CAN USEIT.</b>&nbsp;&nbsp;In Windows you do this with the <b>format</b> command, and in Linux youwill use the <b>mke2fs</b> command.</P><P>When you install Linux, you will have had to specify a partitionfor Linux Swap, and at least one partition Linux-Native.&nbsp;&nbsp;</p><p>At a later point in the install, Linux will look for partitions stamped with theTYPE it is expecting and then ask you to format them with mke2fs.</p><p>Windows will also look for Partitions stamped with the TYPE it isexpecting, AND, it will limit itself to playing only with partitions ofits TYPE during the install.</p><p>If you partition all your drives properly beforeinstalling either Linux or Windows, then the installations of both ofthese will be a breeze.</P></BLOCKQUOTE><P><BR><BR></P><P><BR><BR></P><H2>Hmn...</H2><br><P></P><BLOCKQUOTE><P>We just learned that another good reason for partitions is so thatdifferent operating systems can exist on the hard disk drives of onecomputer at the same time. - not necessarily that they can all run atthe same time. If you like that idea, find out about <b>vmware.</b></P><P><BR></P></BLOCKQUOTE><br><br><br><H2>Fixing drives that appear to be broken</H2><br><BLOCKQUOTE><P><b>A comment about tools...</b>&nbsp;&nbsp;The fdisk and disk druid that come withLinux are BETTER than ones you're likely to find elsewhere. As amatter of fact, you will probably not be able to effectively set upLinux and Windows... Or Linux and anything else, without Linux' neatotools. </P><br><P><b>WARNING:</b> Because of this you may actually need to use these Linuxtools to wipe-out Linux partitions. I've noticed repeatedly Windows95/98... do not want to touch a partition that is not of their TYPE,however, I think NT's fdisk is significantly more likely to work in such cases.</P><P><BR></P><P><b>The fix...</b>&nbsp;&nbsp;Whatever situation you might find yourself in where Windows orwhatever will not recognize a hard drive that you got from some othersystem, or the same system, you can always <b>BEGIN A LINUXINSTALLATION</b>, and run it up to the point where you get to run thepartitioning tools like fdisk or Disk Druid and use that tool to zapwhatever partitions are there and make new ones of just the righttype for whatever you are doing.</p><p>Often, this means that right after you run the tool and save changes, you must reboot. This is a goodtime to take out Linux from the Floppy and/or CD ROM, and put inwhatever you're wanting to install.</P></BLOCKQUOTE><P><BR><BR><BR></P><H2>Actual output from fdisk</H2><br><BLOCKQUOTE><TABLE WIDTH=499 BORDER=0 CELLPADDING=2 CELLSPACING=0>	<COL WIDTH=495>	<TR>		<TD WIDTH=495 BGCOLOR="#e2e2e2">			<PRE STYLE="text-align: left">[root@localhost /]# fdiskUsing /dev/hda as default device!Command (m for help): pDisk /dev/hda: 255 heads, 63 sectors, 627 cylindersUnits = cylinders of 16065 * 512 bytes   Device Boot    Start       End    Blocks   Id  System/dev/hda1   *         1       255   2048256    b  Win95 FAT32/dev/hda2           256       627   2988090    5  Extended/dev/hda5           256       587   2666758+  83  Linux/dev/hda6           588       620    265041   82  Linux swap</PRE><BLOCKQUOTE STYLE="text-align: left">			<FONT FACE="Arial, Helvetica"><B><FONT SIZE=1>*</FONT></B>I have			Windows 98 and RedHat Linux 6.0</FONT> 			</BLOCKQUOTE></FONT>		</TD>	</TR></TABLE></BLOCKQUOTE><BLOCKQUOTE><P>I have only 1 5GB IDE Hard Disk Drive. By looking at the output offdisk you can tell that Linux knows my hard drive as /dev/hda - right?</p><p>Looking at this output tells me is that I have 4 partitions, two for Windows 98 and two forLinux.</p><p>The Windows 98 partition is the one that is bootable.</p><p>HOWEVER, by default my machine boots Linux.</p><p>That is because I used The Linux Loader &quot;<b>lilo</b>&quot; and itcreated the Master Boot Record on this hard drive.</p><p>Lilo is a program that sets up your computer to boot.</p><p>It is very capable, but ordinarily, I expect you'll find it willsetup to boot Linux - until you get good at it.</p><P>Interestingly, as a result of my RedHat install's execution of Lilo, and my havingfirst installed Windows98, my /boot directory contains the original boot image that Windows98 installed on /dev/hda1, and Ican put it back anytime using the lilo command.</p><p>You'll need to read up on it, try &quot;man lilo&quot; </p><BR><BR><b>Note:</b> In order to get fdisk to point to the particular harddisk drive you want to be working with, if different from the defaultone, you need to tell it to do so, either on the command-line or fromthe menu you get when entering &quot;m&quot;</BLOCKQUOTE><BR><BR><H2>A note on booting...</H2><br><BLOCKQUOTE><p>Here's a neat know-how... If ever I wanted to boot off of a Linuxbootable floppy disk, a prompt will come up.</p><p>After some time, Linux will boot from the floppy.</p><p>HOWEVER, if I type &quot;boot vmlinuz root=/dev/hda5&quot; beforeLilo kicks-in automatically, Linux will boot THE WAY I TELL IT TO, in this case, assigning /dev/hda5 tothe root &quot;/&quot; of my directory tree.&nbsp;&nbsp;</p><p>See ?&nbsp;&nbsp;We used the name &quot;root&quot; to mean the root of our directory tree !</p><p>Still with me ?</p><p>The only thing that will come from the floppy in this example will be the image of the Linux kernel that willrun.</p><p>Linux people have a tendency to know more about their hardware than Windows people...&nbsp;&nbsp;I know that /dev/hda5 is where I originally assignedthe root of my directory tree. <b>HINT-HINT</b></p><p>You can play tricks and have multiple partitions with the appropriate contents for a directory root...</p><p>At boot time you can pick one.&nbsp;&nbsp;This is neato for testing out variousconfigurations of your Linux. - OR recovering if you accidentlydeleted necessary things from the root you were working in</p><p>To be tricky like that, you'll need to remember what I said about /etc containing all the good configuration files, as it wouldbe no good whatsoever to mount a new root directory, containing an /etc directory, which then tries, or doesn't try, to mount the right partitions...  That is, the config files in one place may no longer be appropriate if you change things around.</p><p>It is very good to know how to be tricky like that.  A simple example of why:  You HAD two IDE drives, Windows on the first one, Linux on the second.You get rid of your Windows drive, and now have just the Linux drive (which just changed names from /dev/hdb to /dev/hda).</p><p>See that ?  Try and boot now, and by the way, FAIL - and not just because you forgot about IDE's master/slave relationship.</p><p>The RIGHT WAY to do that is to first edit the fstab-like files in /etc to say /dev/hda before you yank the Windows drive and reboot.</p><p>Oops, you can also do all this with the boot prompt that comes from your Master BootRecord, that is, not using a floppy - if it is working...  I mentioned the floppy thingassuming you broke the Master Boot Record ;)</p><p>You have made an emergency boot floppy, right ?&nbsp;&nbsp;You should look that up too.</p></BLOCKQUOTE><BR><BR><H2>A note on performance</H2><br><BLOCKQUOTE><p>One of the final considerations when partitioning is PERFORMANCE.</p><p>For example, it might be a good idea to put database index files on one physical hard disk drive, and thedatabase data files on another, and the database log files on yet another... all on separate hard disk drives.</p><p>This has the effect of maximizing the efficiencies of mechanical bottlenecks... Linux cansimultaneously read indexes, write data to data tables, and append to logs, without waiting for any one hard disk to finish doing somethingbefore it begins something else on another.</p><p>Processing speed far exceeds hard drive speed.</p></BLOCKQUOTE><BR><BR><H2>A note on backups</H2><br><BLOCKQUOTE><p>I'd have to lookup the command, since I never use that sort of thinganymore, but you can backup and restore an <b>image</b> of a partition.</p><P>This is not a file by file backup, but a binary image of the wholepartition.</p><p>It is a good idea if you like to do things this way NOT tomake your partitions bigger than your backup media... i.e., You'llprobably want an image backup of a partition to fit on a single tapeor zip disk, right ? - Think about it</p></BLOCKQUOTE><BR><BR><H2>Ta dah ! There</H2><BLOCKQUOTE><p>Now you're a guru... Almost, anyway, all you need to do now is try andtry again until you have the experience to go with all this ;) </P></BLOCKQUOTE><BR><BR><H2>Errors in this document</H2><BLOCKQUOTE><p>Evidently, you can run SWAP as a FILE the way Windows does and you don't have to havea SWAP partition...  I don't know anybody who does that -FYI  But also I didn't know that,so I guess I'd better <b>RTFM!</b></P></BLOCKQUOTE><BR><BR><H2>Your mission, should you choose to accept it...</H2><BLOCKQUOTE><p>I intend to add some sections regarding how to measure how big a partition should be before you make it,basically this means running "df -k" and "du -ks" and taking a look at something first...</P><p>I'm curious what effect this document has on someone who has either never set up Linux before, or who really isn't very good at it yet.</p><p><b>SO SEND ME YOUR COMMENTS AND EXPERIENCES IF YOU ARE GOOD AT EXPRESSING YOURSELF</b></p></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></FONT></BLOCKQUOTE></FONT></BODY></HTML>

⌨️ 快捷键说明

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