/[gentoo]/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml
Gentoo

Contents of /xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download) (as text)
Mon Aug 22 17:18:23 2011 UTC (3 years, 4 months ago) by swift
Branch: MAIN
Changes since 1.13: +7 -7 lines
File MIME type: application/xml
Fix bug #334167 - Mention ext4 in the handbook. Done for alpha, mips, amd64 and x86. Other arches: please verify and comment on the bug. Thanks to Maciej Grela for reporting.

1 neysx 1.1 <?xml version='1.0' encoding='UTF-8'?>
2     <!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3    
4     <!-- The content of this document is licensed under the CC-BY-SA license -->
5     <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6    
7 swift 1.14 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml,v 1.13 2009/01/26 08:04:26 nightmorph Exp $ -->
8 neysx 1.1
9     <sections>
10    
11 neysx 1.4 <abstract>
12     To be able to install Gentoo, you must create the necessary partitions.
13     This chapter describes how to partition a disk for future usage.
14     </abstract>
15    
16 swift 1.14 <version>7</version>
17     <date>2011-08-22</date>
18 neysx 1.1
19     <section>
20     <title>Introduction to Block Devices</title>
21 nightmorph 1.10
22 neysx 1.1 <subsection>
23 nightmorph 1.10 <include href="hb-install-blockdevices.xml"/>
24     </subsection>
25 neysx 1.1
26     <subsection>
27     <title>Partitions</title>
28     <body>
29    
30     <p>
31     Although it is theoretically possible to use a full disk to house your Linux
32     system, this is almost never done in practice. Instead, full disk block devices
33 neysx 1.2 are split up in smaller, more manageable block devices. On <keyval id="arch"/>
34     systems, these are called <e>partitions</e>.
35 neysx 1.1 </p>
36    
37     <p>
38     Partitions are divided in three types:
39     <e>primary</e>, <e>extended</e> and <e>logical</e>.
40     </p>
41    
42     <p>
43     A <e>primary</e> partition is a partition which has its information stored in
44     the MBR (master boot record). As an MBR is very small (512 bytes) only four
45 nightmorph 1.11 primary partitions can be defined (for instance, <path>/dev/sda1</path> to
46     <path>/dev/sda4</path>).
47 neysx 1.1 </p>
48    
49     <p>
50     An <e>extended</e> partition is a special primary partition (meaning the
51     extended partition must be one of the four possible primary partitions) which
52     contains more partitions. Such a partition didn't exist originally, but as
53     four partitions were too few, it was brought to life to extend the formatting
54     scheme without losing backward compatibility.
55     </p>
56    
57     <p>
58     A <e>logical</e> partition is a partition inside the extended partition. Their
59     definitions aren't placed inside the MBR, but are declared inside the extended
60     partition.
61     </p>
62    
63     </body>
64     </subsection>
65     <subsection>
66     <title>Advanced Storage</title>
67     <body>
68    
69     <p>
70 neysx 1.2 The <keyval id="arch"/> Installation CDs provide support for EVMS and LVM2.
71     EVMS and LVM2 increase the flexibility offered by your partitioning setup.
72     During the installation instructions, we will focus on "regular" partitions,
73     but it is still good to know EVMS and LVM2 are supported as well.
74 neysx 1.1 </p>
75    
76     </body>
77     </subsection>
78     </section>
79     <section>
80     <title>Designing a Partitioning Scheme</title>
81     <subsection>
82     <title>Default Partitioning Scheme</title>
83     <body>
84    
85     <p>
86     If you are not interested in drawing up a partitioning scheme for your system,
87     you can use the partitioning scheme we use throughout this book:
88     </p>
89    
90     <table>
91     <tr>
92     <th>Partition</th>
93     <th>Filesystem</th>
94     <th>Size</th>
95     <th>Description</th>
96     </tr>
97     <tr>
98 nightmorph 1.11 <ti><path>/dev/sda1</path></ti>
99 neysx 1.1 <ti>ext2</ti>
100     <ti>32M</ti>
101     <ti>Boot partition</ti>
102     </tr>
103     <tr>
104 nightmorph 1.11 <ti><path>/dev/sda2</path></ti>
105 neysx 1.1 <ti>(swap)</ti>
106     <ti>512M</ti>
107     <ti>Swap partition</ti>
108     </tr>
109     <tr>
110 nightmorph 1.11 <ti><path>/dev/sda3</path></ti>
111 neysx 1.1 <ti>ext3</ti>
112     <ti>Rest of the disk</ti>
113     <ti>Root partition</ti>
114     </tr>
115     </table>
116    
117     <p>
118     If you are interested in knowing how big a partition should be, or even how
119     many partitions you need, read on. Otherwise continue now with partitioning
120     your disk by reading <uri link="#fdisk">Using fdisk to Partition your
121     Disk</uri>.
122     </p>
123    
124     </body>
125     </subsection>
126     <subsection>
127     <title>How Many and How Big?</title>
128     <body>
129    
130     <p>
131     The number of partitions is highly dependent on your environment. For instance,
132     if you have lots of users, you will most likely want to have your
133     <path>/home</path> separate as it increases security and makes backups easier.
134     If you are installing Gentoo to perform as a mailserver, your
135     <path>/var</path> should be separate as all mails are stored inside
136     <path>/var</path>. A good choice of filesystem will then maximise your
137     performance. Gameservers will have a separate <path>/opt</path> as most gaming
138     servers are installed there. The reason is similar for <path>/home</path>:
139     security and backups. You will definitely want to keep <path>/usr</path> big:
140     not only will it contain the majority of applications, the Portage tree alone
141     takes around 500 Mbyte excluding the various sources that are stored in it.
142     </p>
143    
144     <p>
145     As you can see, it very much depends on what you want to achieve. Separate
146     partitions or volumes have the following advantages:
147     </p>
148    
149     <ul>
150     <li>
151     You can choose the best performing filesystem for each partition or volume
152     </li>
153     <li>
154     Your entire system cannot run out of free space if one defunct tool is
155     continuously writing files to a partition or volume
156     </li>
157     <li>
158     If necessary, file system checks are reduced in time, as multiple checks can
159     be done in parallel (although this advantage is more with multiple disks than
160     it is with multiple partitions)
161     </li>
162     <li>
163     Security can be enhanced by mounting some partitions or volumes read-only,
164     nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc.
165     </li>
166     </ul>
167    
168     <p>
169 neysx 1.2 However, multiple partitions have one big disadvantage: if not configured
170     properly, you might result in having a system with lots of free space on one
171     partition and none on another. There is also a 15-partition limit for SCSI and
172     SATA.
173 neysx 1.1 </p>
174    
175     <p>
176     As an example partitioning, we show you one for a 20GB disk, used as a
177     demonstration laptop (containing webserver, mailserver, gnome, ...):
178     </p>
179    
180     <pre caption="Filesystem usage example">
181     $ <i>df -h</i>
182     Filesystem Type Size Used Avail Use% Mounted on
183 nightmorph 1.11 /dev/sda5 ext3 509M 132M 351M 28% /
184     /dev/sda2 ext3 5.0G 3.0G 1.8G 63% /home
185     /dev/sda7 ext3 7.9G 6.2G 1.3G 83% /usr
186     /dev/sda8 ext3 1011M 483M 477M 51% /opt
187     /dev/sda9 ext3 2.0G 607M 1.3G 32% /var
188     /dev/sda1 ext2 51M 17M 31M 36% /boot
189     /dev/sda6 swap 516M 12M 504M 2% &lt;not mounted&gt;
190 neysx 1.1 <comment>(Unpartitioned space for future usage: 2 GB)</comment>
191     </pre>
192    
193     <p>
194     <path>/usr</path> is rather full (83% used) here, but once
195     all software is installed, <path>/usr</path> doesn't tend to grow that much.
196     Although allocating a few gigabytes of disk space for <path>/var</path> may
197     seem excessive, remember that Portage uses this partition by default for
198     compiling packages. If you want to keep <path>/var</path> at a more reasonable
199     size, such as 1GB, you will need to alter your <c>PORTAGE_TMPDIR</c> variable
200     in <path>/etc/make.conf</path> to point to the partition with enough free space
201     for compiling extremely large packages such as OpenOffice.
202     </p>
203    
204     </body>
205     </subsection>
206     </section>
207     <section id="fdisk">
208     <title>Using fdisk to Partition your Disk</title>
209     <subsection>
210     <body>
211    
212     <p>
213     The following parts explain how to create the example partition layout
214     described previously, namely:
215     </p>
216    
217     <table>
218     <tr>
219     <th>Partition</th>
220     <th>Description</th>
221     </tr>
222     <tr>
223 nightmorph 1.11 <ti><path>/dev/sda1</path></ti>
224 neysx 1.1 <ti>Boot partition</ti>
225     </tr>
226     <tr>
227 nightmorph 1.11 <ti><path>/dev/sda2</path></ti>
228 neysx 1.1 <ti>Swap partition</ti>
229     </tr>
230     <tr>
231 nightmorph 1.11 <ti><path>/dev/sda3</path></ti>
232 neysx 1.1 <ti>Root partition</ti>
233     </tr>
234     </table>
235    
236     <p>
237     Change your partition layout according to your own preference.
238     </p>
239    
240     </body>
241     </subsection>
242     <subsection>
243     <title>Viewing the Current Partition Layout</title>
244     <body>
245    
246     <p>
247     <c>fdisk</c> is a popular and powerful tool to split your disk into partitions.
248     Fire up <c>fdisk</c> on your disk (in our example, we use
249 nightmorph 1.11 <path>/dev/sda</path>):
250 neysx 1.1 </p>
251    
252     <pre caption="Starting fdisk">
253 nightmorph 1.11 # <i>fdisk /dev/sda</i>
254 neysx 1.1 </pre>
255    
256     <p>
257     Once in <c>fdisk</c>, you'll be greeted with a prompt that looks like this:
258     </p>
259    
260     <pre caption="fdisk prompt">
261     Command (m for help):
262     </pre>
263    
264     <p>
265     Type <c>p</c> to display your disk's current partition configuration:
266     </p>
267    
268     <pre caption="An example partition configuration">
269     Command (m for help): <i>p</i>
270    
271 nightmorph 1.11 Disk /dev/sda: 240 heads, 63 sectors, 2184 cylinders
272 neysx 1.1 Units = cylinders of 15120 * 512 bytes
273    
274 neysx 1.12 Device Boot Start End Blocks Id System
275     /dev/sda1 * 1 14 105808+ 83 Linux
276 nightmorph 1.11 /dev/sda2 15 49 264600 82 Linux swap
277     /dev/sda3 50 70 158760 83 Linux
278     /dev/sda4 71 2184 15981840 5 Extended
279     /dev/sda5 71 209 1050808+ 83 Linux
280     /dev/sda6 210 348 1050808+ 83 Linux
281     /dev/sda7 349 626 2101648+ 83 Linux
282     /dev/sda8 627 904 2101648+ 83 Linux
283     /dev/sda9 905 2184 9676768+ 83 Linux
284 neysx 1.1
285     Command (m for help):
286     </pre>
287    
288     <p>
289 neysx 1.2 This particular disk is configured to house seven Linux filesystems (each with
290     a corresponding partition listed as "Linux") as well as a swap partition
291     (listed as "Linux swap").
292 neysx 1.1 </p>
293    
294     </body>
295     </subsection>
296     <subsection>
297     <title>Removing all Partitions</title>
298     <body>
299    
300     <p>
301     We will first remove all existing partitions from the disk. Type <c>d</c> to
302 nightmorph 1.11 delete a partition. For instance, to delete an existing <path>/dev/sda1</path>:
303 neysx 1.1 </p>
304    
305     <pre caption="Deleting a partition">
306     Command (m for help): <i>d</i>
307     Partition number (1-4): <i>1</i>
308     </pre>
309    
310     <p>
311     The partition has been scheduled for deletion. It will no longer show up if you
312     type <c>p</c>, but it will not be erased until your changes have been saved. If
313     you made a mistake and want to abort without saving your changes, type <c>q</c>
314     immediately and hit enter and your partition will not be deleted.
315     </p>
316    
317     <p>
318     Now, assuming that you do indeed want to wipe out all the partitions on your
319     system, repeatedly type <c>p</c> to print out a partition listing and then type
320     <c>d</c> and the number of the partition to delete it. Eventually, you'll end
321     up with a partition table with nothing in it:
322     </p>
323    
324     <pre caption="An empty partition table">
325 nightmorph 1.11 Disk /dev/sda: 30.0 GB, 30005821440 bytes
326 neysx 1.1 240 heads, 63 sectors/track, 3876 cylinders
327     Units = cylinders of 15120 * 512 = 7741440 bytes
328    
329     Device Boot Start End Blocks Id System
330    
331     Command (m for help):
332     </pre>
333    
334     <p>
335     Now that the in-memory partition table is empty, we're ready to create the
336     partitions. We will use a default partitioning scheme as discussed previously.
337     Of course, don't follow these instructions to the letter if you don't want the
338     same partitioning scheme!
339     </p>
340    
341     </body>
342     </subsection>
343     <subsection>
344     <title>Creating the Boot Partition</title>
345     <body>
346    
347     <p>
348     We first create a small boot partition. Type <c>n</c> to create a new partition,
349     then <c>p</c> to select a primary partition, followed by <c>1</c> to select the
350     first primary partition. When prompted for the first cylinder, hit enter. When
351     prompted for the last cylinder, type <c>+32M</c> to create a partition 32 Mbyte
352 neysx 1.12 in size and set its bootable flag:
353 neysx 1.1 </p>
354    
355     <pre caption="Creating the boot partition">
356     Command (m for help): <i>n</i>
357     Command action
358     e extended
359     p primary partition (1-4)
360     <i>p</i>
361     Partition number (1-4): <i>1</i>
362     First cylinder (1-3876, default 1): <comment>(Hit Enter)</comment>
363     Using default value 1
364     Last cylinder or +size or +sizeM or +sizeK (1-3876, default 3876): <i>+32M</i>
365     </pre>
366    
367     <p>
368     Now, when you type <c>p</c>, you should see the following partition printout:
369     </p>
370    
371     <pre caption="Created boot partition">
372     Command (m for help): <i>p</i>
373    
374 nightmorph 1.11 Disk /dev/sda: 30.0 GB, 30005821440 bytes
375 neysx 1.1 240 heads, 63 sectors/track, 3876 cylinders
376     Units = cylinders of 15120 * 512 = 7741440 bytes
377    
378 neysx 1.12 Device Boot Start End Blocks Id System
379     /dev/sda1 1 14 105808+ 83 Linux
380 neysx 1.1 </pre>
381    
382     <p>
383     We need to make this partition bootable. Type <c>a</c> to toggle the bootable
384 neysx 1.12 flag on a partition and select <c>1</c>. If you press <c>p</c> again, you will
385 neysx 1.1 notice that an <path>*</path> is placed in the "Boot" column.
386     </p>
387    
388     </body>
389     </subsection>
390     <subsection>
391     <title>Creating the Swap Partition</title>
392     <body>
393    
394     <p>
395     Let's now create the swap partition. To do this, type <c>n</c> to create a new
396     partition, then <c>p</c> to tell fdisk that you want a primary partition. Then
397 nightmorph 1.11 type <c>2</c> to create the second primary partition, <path>/dev/sda2</path> in
398 neysx 1.1 our case. When prompted for the first cylinder, hit enter. When prompted for
399     the last cylinder, type <c>+512M</c> to create a partition 512MB in size. After
400     you've done this, type <c>t</c> to set the partition type, <c>2</c> to select
401     the partition you just created and then type in <c>82</c> to set the partition
402     type to "Linux Swap". After completing these steps, typing <c>p</c> should
403     display a partition table that looks similar to this:
404     </p>
405    
406     <pre caption="Partition listing after creating a swap partition">
407     Command (m for help): <i>p</i>
408    
409 nightmorph 1.11 Disk /dev/sda: 30.0 GB, 30005821440 bytes
410 neysx 1.1 240 heads, 63 sectors/track, 3876 cylinders
411     Units = cylinders of 15120 * 512 = 7741440 bytes
412    
413 neysx 1.12 Device Boot Start End Blocks Id System
414     /dev/sda1 * 1 14 105808+ 83 Linux
415     /dev/sda2 15 81 506520 82 Linux swap
416 neysx 1.1 </pre>
417    
418     </body>
419     </subsection>
420     <subsection>
421     <title>Creating the Root Partition</title>
422     <body>
423    
424     <p>
425     Finally, let's create the root partition. To do this, type <c>n</c> to create a
426     new partition, then <c>p</c> to tell fdisk that you want a primary partition.
427 nightmorph 1.11 Then type <c>3</c> to create the third primary partition, <path>/dev/sda3</path>
428 neysx 1.1 in our case. When prompted for the first cylinder, hit enter. When prompted for
429     the last cylinder, hit enter to create a partition that takes up the rest of the
430     remaining space on your disk. After completing these steps, typing <c>p</c>
431     should display a partition table that looks similar to this:
432     </p>
433    
434     <pre caption="Partition listing after creating the root partition">
435     Command (m for help): <i>p</i>
436    
437 nightmorph 1.11 Disk /dev/sda: 30.0 GB, 30005821440 bytes
438 neysx 1.1 240 heads, 63 sectors/track, 3876 cylinders
439     Units = cylinders of 15120 * 512 = 7741440 bytes
440    
441 neysx 1.12 Device Boot Start End Blocks Id System
442     /dev/sda1 * 1 14 105808+ 83 Linux
443     /dev/sda2 15 81 506520 82 Linux swap
444     /dev/sda3 82 3876 28690200 83 Linux
445 neysx 1.1 </pre>
446    
447     </body>
448     </subsection>
449     <subsection>
450     <title>Saving the Partition Layout</title>
451     <body>
452    
453     <p>
454     To save the partition layout and exit <c>fdisk</c>, type <c>w</c>.
455     </p>
456    
457     <pre caption="Save and exit fdisk">
458     Command (m for help): <i>w</i>
459     </pre>
460    
461     <p>
462 nightmorph 1.13 Now that your partitions are created, you can continue with <uri
463 neysx 1.1 link="#filesystems">Creating Filesystems</uri>.
464     </p>
465    
466     </body>
467     </subsection>
468     </section>
469     <section id="filesystems">
470     <title>Creating Filesystems</title>
471     <subsection>
472     <title>Introduction</title>
473     <body>
474    
475     <p>
476     Now that your partitions are created, it is time to place a filesystem on them.
477     If you don't care about what filesystem to choose and are happy with what we use
478     as default in this handbook, continue with <uri
479     link="#filesystems-apply">Applying a Filesystem to a Partition</uri>.
480     Otherwise read on to learn about the available filesystems...
481     </p>
482    
483     </body>
484     </subsection>
485 nightmorph 1.10
486 neysx 1.1 <subsection>
487 nightmorph 1.10 <include href="hb-install-filesystems.xml"/>
488     </subsection>
489 neysx 1.1
490     <subsection id="filesystems-apply">
491     <title>Applying a Filesystem to a Partition</title>
492     <body>
493    
494     <p>
495     To create a filesystem on a partition or volume, there are tools available for
496     each possible filesystem:
497     </p>
498    
499     <table>
500     <tr>
501     <th>Filesystem</th>
502     <th>Creation Command</th>
503     </tr>
504     <tr>
505     <ti>ext2</ti>
506 swift 1.14 <ti><c>mkfs.ext2</c></ti>
507 neysx 1.1 </tr>
508     <tr>
509     <ti>ext3</ti>
510 swift 1.14 <ti><c>mkfs.ext3</c></ti>
511 neysx 1.1 </tr>
512     <tr>
513     <ti>reiserfs</ti>
514     <ti><c>mkreiserfs</c></ti>
515     </tr>
516     <tr>
517     <ti>xfs</ti>
518     <ti><c>mkfs.xfs</c></ti>
519     </tr>
520     <tr>
521     <ti>jfs</ti>
522     <ti><c>mkfs.jfs</c></ti>
523     </tr>
524     </table>
525    
526     <p>
527 nightmorph 1.11 For instance, to have the boot partition (<path>/dev/sda1</path> in our
528     example) in ext2 and the root partition (<path>/dev/sda3</path> in our example)
529 neysx 1.1 in ext3 (as in our example), you would use:
530     </p>
531    
532     <pre caption="Applying a filesystem on a partition">
533 swift 1.14 # <i>mkfs.ext2 /dev/sda1</i>
534     # <i>mkfs.ext3 /dev/sda3</i>
535 neysx 1.1 </pre>
536    
537     <p>
538     Now create the filesystems on your newly created partitions (or logical
539     volumes).
540     </p>
541    
542     </body>
543     </subsection>
544     <subsection>
545     <title>Activating the Swap Partition</title>
546     <body>
547    
548     <p>
549     <c>mkswap</c> is the command that is used to initialize swap partitions:
550     </p>
551    
552     <pre caption="Creating a Swap signature">
553 nightmorph 1.11 # <i>mkswap /dev/sda2</i>
554 neysx 1.1 </pre>
555    
556     <p>
557     To activate the swap partition, use <c>swapon</c>:
558     </p>
559    
560     <pre caption="Activating the swap partition">
561 nightmorph 1.11 # <i>swapon /dev/sda2</i>
562 neysx 1.1 </pre>
563    
564     <p>
565     Create and activate the swap with the commands mentioned above.
566     </p>
567    
568     </body>
569     </subsection>
570     </section>
571     <section>
572     <title>Mounting</title>
573     <body>
574    
575     <p>
576     Now that your partitions are initialized and are housing a filesystem, it is
577     time to mount those partitions. Use the <c>mount</c> command. Don't forget to
578     create the necessary mount directories for every partition you created. As an
579     example we mount the root and boot partition:
580     </p>
581    
582     <pre caption="Mounting partitions">
583 nightmorph 1.11 # <i>mount /dev/sda3 /mnt/gentoo</i>
584 neysx 1.1 # <i>mkdir /mnt/gentoo/boot</i>
585 nightmorph 1.11 # <i>mount /dev/sda1 /mnt/gentoo/boot</i>
586 neysx 1.1 </pre>
587    
588     <note>
589     If you want your <path>/tmp</path> to reside on a separate partition, be sure to
590     change its permissions after mounting: <c>chmod 1777 /mnt/gentoo/tmp</c>. This
591     also holds for <path>/var/tmp</path>.
592     </note>
593    
594     <p>
595     We will also have to mount the proc filesystem (a virtual interface with the
596     kernel) on <path>/proc</path>. But first we will need to place our files on the partitions.
597     </p>
598    
599     <p>
600     Continue with <uri link="?part=1&amp;chap=5">Installing the Gentoo
601     Installation Files</uri>.
602     </p>
603    
604     </body>
605     </section>
606     </sections>

  ViewVC Help
Powered by ViewVC 1.1.20