📄 linux-partition.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD> <TITLE></TITLE> <META NAME="GENERATOR" CONTENT="StarOffice/5.1 (Linux)"> <META NAME="AUTHOR" CONTENT="Allen Francom"> <META NAME="CREATED" CONTENT="19990921;8483200"> <META NAME="CHANGEDBY" CONTENT="Allen Francom"> <META NAME="CHANGED" CONTENT="19990921;9112900"> <STYLE> <!-- BLOCKQUOTE { color: #000000 } PRE { color: #000000 } --> </STYLE></HEAD><BODY><P>Linux hard disk partitioning</P><P>Created September 14, 1999</P><P>Last modified September 15, 1999</P><P>Written by Allen Francom (aef@prismnet.com)</P><P><BR><BR></P><P><BR><BR></P><P><BR><BR></P><BLOCKQUOTE><FONT SIZE=4><BLOCKQUOTE><FONT SIZE=4><H2>Purpose</H2><br><br><BLOCKQUOTE><FONT SIZE=4><P>This document is intended to explain partitions, why they areused, and how they are used.</P><P>The goal is to provide enough information so that the readerwanting to discover how and when to mount what, where; will be ableto make up their own mind.</P><P>The premise is, nobody can properly scratch you because you're theonly one that knows where it itches.</P><P>- Same thing with your own partitions...</P><P><BR><BR></P><P>Hopefully,</P><UL><LI><P>The beginner will learn a lot, really well, really fast</P><LI><P>The novice will gain a proper context and reassurance prior toproceeding with a partitioning endeavor</P><LI><p>Guru's who are not yet familiar with Linux should be able to get everything they need out of this</p><LI><P>Real Guru's will occasionally review this and let me know what I don'talready know, or thought I knew, and then I'll include it here infuture releases.</P></UL></BLOCKQUOTE></FONT><P><BR><BR></P><H2>Required</H2><BR><BLOCKQUOTE><FONT SIZE=4><P>You must know what a Directory Tree is or this document will notwork for you until you ask someome, or become enlightened otherwise.</P><P>You should have at least rudimentary skills at running simple things from the Linux command-line.</p><p>Which implies you should have some level of experience with computers, say the DOS command-line.</p><p>( don't say "What's DOS ?" - Don't )</p><P>You should know how to read "man" pages.</p><p>You should know how to edit text files</p><P>Check 'em for bees... Know that joke ?</p><p>Hints:</p><UL><LI>cd /home - example of changing directories<LI>man cd - example of reading the man page on the cd command<LI>vi mytextfile - example of editing a text file<LI>":q!" - example of how to get out of the stupid vi editor<LI>man vi - example of learning how to use the vi editor<LI>"q" - example of how to get out of the "man" program and back to the command prompt</UL><p>It would maybe be a good idea to have a RUNNING Linux machine you can look at while you read this.</p><p>It would be great if you could be using an HTML browser running on a Linux machine while you read this. A pretty one, like Netscape.</p></BLOCKQUOTE></FONT><P><BR><BR></P><H2>Introduction</H2><br><BLOCKQUOTE><FONT SIZE=4><P>Like a partition in an office, a hard disk partition is a chunk ofspace allocated for a particular purpose... A particular person orentity is going to use that space, and in that space are going to bethings.</P><P>Usually, these things on a hard disk are <b>files</b> and the entity thatuses them is the operating system's <b>File System.</b> Users then runprograms that talk to the operating system, which runs the filesystem, which reads and writes data inside of particular hard drivepartitions.</P><P>Another way to say this, perhaps, is that a hard disk partition isa logical separation of storage capacity on a given physical device.- cute</P><P>Hard disk drives may have many partitions, or just one big one inorder to be of any use. You are not likely to see situations wherethat is not true.</P><P>Each hard disk drive, therefore, is expected to have a <b>PartitionTable</b> that identifies the <b>offsets</b>, <b>sizes</b>, and <b>types</b> ofpartitions present at the moment.</P><P>You will see later on that the partition table is of primaryimportance to operating systems, as it allows them to know aboutwhere everything is expected to be, enough for them to get started atleast. This is because an operating system can always expect to findthe partition table in exactly the same place on any hard disk drive.</P><P>The partition table is one of the only things about a hard diskdrive that an OS can properly read from the drive, if it is present,as an operating system begins to boot up. The partition table must beread FIRST, before the Operating System will be able to know enoughto do anything else with the given drive.</P><P>Partitions containing File Systems are <b>Formatted</b> according todifferent standards, depending on the Operating System that createdthem. Formatting is a separate step.</P><P>Some Operating Systems, like Linux, know how to read and write topartitions in a wide variety of native formats. You can imagine thatthe Partition Type stored in the Partition Table comes in very handy. Almost always, commands that format partitions first check thepartition's type, and abort if it doesn't match what is expected.</P><P>Also, when you define a partition its definition is stored on thegiven hard disk drive's partition table, and therefore the partitiontable is also important to you as you will need to be able to readfrom it and write to it in order to make changes and partition yourdrives the way you want.</P><P><b>Partitioning</b> is the art of designing and implementing partitionson your hard drives, primarily for the purpose of constructing yourdirectory tree in a manner that will be most efficient for your useof it, and for the Operating System's overall performance.</P><BR><P><b>Running Linux requires at least two hard disk partitions:</b></P><P><BR></P><P>1.<b>The Swap Partition</b></P><BLOCKQUOTE><FONT SIZE=4><P>The swap partition is basically a place for the computer topretend like it has more RAM than it actually does.</P><P>A good rule of thumb is to allocate a "Swap Partition"that is at least twice as big as your physical RAM. If you have 64MBRAM, then make at least a 128MB Swap Partition.</P><P>Commands useful for setting-up and fixing swap space:</P><UL><LI><P>fdisk</P><LI><P>mkswap</P><LI><P>swapon</P></UL><P><BR><BR></P></BLOCKQUOTE></FONT><P>Note: The setup and initial configuration of swap space is usuallyhandled by Linux install programs. These commands are for you to useonly if you need to work on swap space manually for some reason.Quite probably, you'll never need to use "mkswap" and"swapon".</P><P><BR><BR></P><P>2.<b>The Root Partition</b></P><BLOCKQUOTE><FONT SIZE=4><P>"/" is the root of the directory tree on Unix machines.</P><P>Do not confuse this "root" with the Super User accountof the same name. One is the root of your directory tree, and theother root is the Linux User Account that get's to do darn wellwhatever it pleases.</p><p>To make matters worse, there is, on my machine,a "/root" directory as well. This is the HOME directory ofthe root user account, and not the root of the directory tree. Got it?</P><P>There is NO DRIVE IDENTIFIER on Unix systems.</P><P>Partitions on almost any number of drives drives can be mountedstarting at some point in the directory tree under /.</P><P>Commands useful for mapping your directory tree, and/or portionsthereof, to hard disk partitions:</P><UL><LI><P>mount</P><LI><P>umount</P></UL><br><br></BLOCKQUOTE></FONT><P>Note: You will most likely use these commands day-to-day in orderto mount floppy disks, CD-ROMs, etc., These same two commands mounthard disk partitions to specific points within your directory tree.</P><P>*You do not normally see the swap partition in the directory tree,as it is ordinarily directly accessible only by the kernel of theoperating system. The swap partition is not mounted and unmountedwith these commands.</P></BLOCKQUOTE></FONT><br><br><H2>Psychology-fu</H2><P><BR></P><BLOCKQUOTE><FONT SIZE=4><P>_ _ _ _ is the name given to the top of the directory tree, theuser account that has the most permissions, and, in my case, thatuser account's HOME directory.</P><P>Hard disk drives have to have one or more _ _ _ _ _ _ _ _ _s inorder to be usable by an Operating System like Linux or Windows.</P><P>Linux requires at least two partitions, one for _ _ _ _ and atleast one for mapping into the directory tree.</P><P>Every hard disk drive is expected by most operating systems tohave a Partition _ _ _ _ _, which identifies all of the drive'spartition t_ _ _ s, offsets, and s_ _ _s.</P><P>Synonymous with actions taken with Floppy Diskettes and CD-ROMdrives, you can allocate hard disk drive partitions to specificlocations within your directory tree by using the commands _ _ _ _ _and un_ _ _ _ _.</P><P>Thus, if you think about it, you or the Linux kernel must _ _ _ __ at least one _ _ _ _ _ _ _ _ _ in order for the directory tree toeven exist. And that is very important, because all of the programs,library files, data files, EVERYTHING needed to run Linux has to bemounted in the directory tree before anything will work.</P><P>Thinking a little bit more, Linux does not have drive identifierslike "C:\" which you find in DOS and Windows because all ofyour hard disks' _ _ _ _ _ _ _ _ _ _ are _ _ _ _ _ed into one bigoverall directory tree starting at a particular directory or MountPoint.</P><P>Installing Linux requires a hard disk partition to be mounted atthe "/" location in your directory tree. I can't think of away around it. Therefore when you are setting up Linux initially, youwill obviously have to somewhere specify and/or create the r_ _ _partition; that is, the partition assigned to the root of thedirectory tree.</P><P>Linux install programs remember what you did in theinstall/configuration phase and they create configuration files inthe /etc directory which tell Linux what partitions to mount andwhere they go in the directory tree - for Linux to refer to when itis booting and getting ready to let you use it initially.</P><P>Another interesting thing about _ _ _ _ _ _ _ _ _s and thedirectory tree is that you can _ _ _ _ _ and un_ _ _ _ _ them at anytime they are not actively being used.</P><P>That statement is loaded ! So let me repeat it in more anddifferent words... You can change what partition, and even whatphysical hard disk drive is corresponding to what part of yourdirectory tree right now ! - if you happen to be running Linux at themoment. - Try that on Windblows...</P><P>Linux and Unixes/en, Unixen, in general are rather moreinteresting than DOS or Windows in this regard, and it gets much muchbetter, in other documents ;)</P><P>The kinds of things you can do with all this flexibility isamazing. This is why partitioning your hard drives for Linux is YOURproblem. There's just so much creativity in what you might want to doand why...</P><P>Let's do one more really quick... Linux' _ _ _ _ partition isnever to be found in the directory tree. To see it you must use fdiskor some other partition software, and although you are unlikely toever do this, to enable and disable the _ _ _ _ partition, you'll usethe _ _ _ _ _ _ and, as you might be able to guess, the _ _ _ _ _ _ _commands.</P></BLOCKQUOTE></FONT><P><BR><BR></P><H2>Determining what partitions you want</H2><P><BR></P><BLOCKQUOTE><FONT SIZE=4><P><b>Simplest Case</b></P><P><BR></P><P>If you like to keep things simple, you'll have two partitions, onefor Swap Space, and one big huge one for everything else. If you dothis, the "Mount Point" for your big huge partition is "/"the root of the directory tree. Period. Every file and directorylives on that big partition. The whole entire directory tree refersonly to stuff in that one partition. Enough said.</P></BLOCKQUOTE></FONT><P><BR></P><BLOCKQUOTE><FONT SIZE=4><P><b>Regarding the directory tree</b></P><P><BR></P><P>What's in it ? And where can you mount partitions ?</P><P>On my RedHat 6.0 system, I have the following out-of-the-boxtop-level directory structure, each of these are directories withmore subdirectories:</P></BLOCKQUOTE></FONT><P><BR><BR></P><P></P><BLOCKQUOTE><FONT SIZE=4><TABLE WIDTH=70% BORDER=0 CELLPADDING=5 CELLSPACING=0> <COL WIDTH=40*> <COL WIDTH=216*> <TR> <TD WIDTH=16% VALIGN=TOP> <P><TT><B>/</B></TT></P> </TD> <TD WIDTH=84% BGCOLOR="#e2e2e2"> <P ALIGN=LEFT><FONT SIZE=4>The root or top of your directory tree <BR><BR><A HREF="file:/">Click here to see your own directory root</A></FONT></P> </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>/bin</B></TT></P> </TD> <TD WIDTH=84% BGCOLOR="#e2e2e2"> <P ALIGN=LEFT><FONT SIZE=4>Programs needed to run your system, commands like cd, ls, etc., programs that most users would be likely to use day to day. <BR><BR><A HREF="file:/bin">Click here to see your own /bin directory</A></FONT></P> </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>/sbin</B></TT></P> </TD> <TD WIDTH=84% BGCOLOR="#e2e2e2"> <P ALIGN=LEFT><FONT SIZE=4>Programs that are more serious, generally, than those in /bin, things like commands to format your hard drive partitions, swapon, etc.,</FONT></P> <P ALIGN=LEFT><FONT SIZE=4>In one fell-swoop you can change the permissions on all the files in this directory so that only special users can run this dangerous programs. <BR><BR><A HREF="file:/sbin">Click here to see your own /sbin directory</A></FONT></P> </TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -