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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 Revision 1.15
2<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> 2<!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3 3
4<!-- The content of this document is licensed under the CC-BY-SA license --> 4<!-- The content of this document is licensed under the CC-BY-SA license -->
5<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> 5<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6 6
7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml,v 1.14 2011/08/22 17:18:23 swift Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml,v 1.15 2011/08/23 17:31:34 swift Exp $ -->
8 8
9<sections> 9<sections>
10 10
11<abstract> 11<abstract>
12To be able to install Gentoo, you must create the necessary partitions. 12To be able to install Gentoo, you must create the necessary partitions.
13This chapter describes how to partition a disk for future usage. 13This chapter describes how to partition a disk for future usage.
14</abstract> 14</abstract>
15 15
16<version>7</version> 16<version>8</version>
17<date>2011-08-22</date> 17<date>2011-08-23</date>
18 18
19<section> 19<section>
20<title>Introduction to Block Devices</title> 20<title>Introduction to Block Devices</title>
21 21
22<subsection> 22<subsection>
116 116
117<p> 117<p>
118If you are interested in knowing how big a partition should be, or even how 118If you are interested in knowing how big a partition should be, or even how
119many partitions you need, read on. Otherwise continue now with partitioning 119many partitions you need, read on. Otherwise continue now with partitioning
120your disk by reading <uri link="#fdisk">Using fdisk to Partition your 120your disk by reading <uri link="#fdisk">Using fdisk to Partition your
121Disk</uri>. 121Disk</uri> or <uri link="#parted">Using parted to Partition your Disk</uri>
122(both are partitioning tools, <c>fdisk</c> is well known and stable,
123<c>parted</c> is a bit more recent but supports partitions larger than
1242TB).
122</p> 125</p>
123 126
124</body> 127</body>
125</subsection> 128</subsection>
126<subsection> 129<subsection>
207<section id="fdisk"> 210<section id="fdisk">
208<title>Using fdisk to Partition your Disk</title> 211<title>Using fdisk to Partition your Disk</title>
209<subsection> 212<subsection>
210<body> 213<body>
211 214
215<impo>
216If your environment will deal with partitions larger than 2 TB, please
217use the <uri link="#parted">Using parted to Partition your Disk</uri>
218instructions instead. <c>fdisk</c> is not able to deal with larger
219partitions.
220</impo>
221
212<p> 222<p>
213The following parts explain how to create the example partition layout 223The following parts explain how to create the example partition layout
214described previously, namely: 224using <c>fdisk</c>. The example partition layout was mentioned earlier:
215</p> 225</p>
216 226
217<table> 227<table>
218<tr> 228<tr>
219 <th>Partition</th> 229 <th>Partition</th>
464</p> 474</p>
465 475
466</body> 476</body>
467</subsection> 477</subsection>
468</section> 478</section>
479<section id="parted">
480<title>Using parted to Partition your Disk</title>
481<subsection>
482<body>
483
484<p>
485In this chapter, we guide you through the creation of the example partition
486layout mentioned earlier in the instructions. Unlike the previous chapter, we
487describe the method using the <c>parted</c> application instead. Both
488<c>parted</c> and <c>fdisk</c> offer the same functions, so if you partitioned
489your system using <c>fdisk</c> already, you can skip this section and continue
490with <uri link="#filesystems">Creating Filesystems</uri>.
491</p>
492
493<p>
494The example partition layout we use is shown in the next table:
495</p>
496
497<table>
498<tr>
499 <th>Partition</th>
500 <th>Description</th>
501</tr>
502<tr>
503 <ti><path>/dev/sda1</path></ti>
504 <ti>Boot partition</ti>
505</tr>
506<tr>
507 <ti><path>/dev/sda2</path></ti>
508 <ti>Swap partition</ti>
509</tr>
510<tr>
511 <ti><path>/dev/sda3</path></ti>
512 <ti>Root partition</ti>
513</tr>
514</table>
515
516<p>
517Change your partition layout according to your own preference.
518</p>
519
520</body>
521</subsection>
522<subsection>
523<title>Viewing the Current Partition Layout</title>
524<body>
525
526<p>
527The <c>parted</c> application is a somewhat more modern variant of
528<c>fdisk</c>. It offers a simpler interface for partitioning your disks and
529supports very large partitions (more than 2 TB). Fire up <c>parted</c> on your
530disk (in our example, we use <path>/dev/sda</path>):
531</p>
532
533<pre caption="Starting parted">
534# <i>parted /dev/sda</i>
535GNU Parted 2.3
536Using /dev/vda
537Welcome to GNU Parted! Type 'help' to view a list of commands.
538</pre>
539
540<p>
541To find out about all options supported by <c>parted</c>, type <c>help</c> and
542press return. For now, we just continue by asking <c>parted</c> to show the
543partitions currently in use on the selected disk. The <c>print</c> command can
544be used for that.
545</p>
546
547<pre caption="An example partition configuration shown by parted">
548(parted) <i>print</i>
549Model: SCSI Block Device
550Disk /dev/sda: 21.5GB
551Sector size (logical/physical): 512B/512B
552Partition Table: msdos
553
554Number Start End Size Type File system Flags
555 1 512B 2148MB 2148MB primary ext4
556 2 2148MB 3222MB 1074MB primary linux-swap(v1)
557 3 3222MB 21.5GB 18.3GB primary lvm
558</pre>
559
560</body>
561</subsection>
562<subsection>
563<title>Optional: Setting the GPT Label</title>
564<body>
565
566<p>
567Most disks on x86/amd64 are prepared using an <e>msdos</e> label. However, if
568you plan on creating huge partitions (2 TB and more), you must use a <e>gpt</e>
569label (the <e>GUID Partition Type</e>) for your disk. Using <c>parted</c>, this
570can be accomplished with <c>mklabel gpt</c>:
571</p>
572
573<warn>
574Changing the partition type will remove all partitions from your disk. All data
575on the disk will be lost.
576</warn>
577
578<pre caption="Setting the GPT label">
579(parted) <i>mklabel gpt</i>
580</pre>
581
582</body>
583</subsection>
584<subsection>
585<title>Removing all Partitions</title>
586<body>
587
588<p>
589If this isn't done yet (for instance through the <c>mklabel</c> operation
590earlier, or because the disk is a freshly formatted one), we will first
591remove all existing partitions from the disk. Type <c>rm &lt;number&gt;</c>
592where &lt;number&gt; is the partition you want to remove.
593</p>
594
595<pre caption="Removing a partition from the disk">
596(parted) <i>rm 2</i>
597</pre>
598
599<p>
600Do the same for all other partitions that you don't need. However, make sure you
601do not make any mistakes here - <c>parted</c> executes the changes immediate
602(unlike <c>fdisk</c> which stages them, allowing a user to "undo" his changes
603before saving or exiting <c>fdisk</c>).
604</p>
605
606</body>
607</subsection>
608<subsection>
609<title>Creating the Partitions</title>
610<body>
611
612<p>
613Now let's create the partitions we mentioned earlier. Creating partitions with
614<c>parted</c> isn't very difficult - all we need to do is inform <c>parted</c>
615about the following settings:
616</p>
617
618<ul>
619 <li>
620 The <e>partition type</e> to use. This usually is <e>primary</e> in case you
621 are not going to have more than 4 partitions (with the <e>msdos</e>
622 partition label). Otherwise, you will need to make your fourth partition an
623 <e>extended</e> one which hosts the rest of the disk, and create
624 <e>logical</e> partitions inside it. If you use a <e>gpt</e>-labeled
625 partition, then there is no limit on the number of primary partitions.
626 </li>
627 <li>
628 The <e>file system type</e> to use. The <c>parted</c> application supports
629 most common file systems and knows which kind of partition ID it needs to
630 use for these partitions. This does <e>not</e> mean that <c>parted</c> will
631 create a file system on the partition (you can with the <c>mkpartfs</c>
632 command, but we'll use the regular <c>mkfs.*</c> commands later for this
633 purpose). The partition ID is often used by auto-detection tools to know
634 what to do with a particular partition.
635 </li>
636 <li>
637 The start location of a partition (which can be expressed in MB or GB)
638 </li>
639 <li>
640 The end location of the partition (which can be expressed in MB or GB)
641 </li>
642</ul>
643
644<p>
645One advantage of <c>parted</c> is that you can easily just use the partition
646sizes to automatically find the correct start and end location as you will see
647in the next example.
648</p>
649
650<pre caption="Creating the partitions">
651<comment># Create a 32 mbyte /boot partition</comment>
652(parted) <i>mkpart primary ext2 0 32mb</i>
653Warning: The resulting partition is not properly aligned for best performance.
654Ignore/Cancel? <i>i</i>
655
656<comment># Create a 512 mbyte swap partition</comment>
657(parted) <i>mkpart primary linux-swap 32mb 542mb</i>
658
659<comment># Create a partition that spans the remaining disk.
660# -1s (minus one s) means the end of the disk</comment>
661(parted) <i>mkpart primary ext4 542mb -1s</i>
662Warning: You requested a partition from 542MB to 21.5GB.
663The closest location we can manage is 542MB to 21.5GB.
664Is this still acceptable to you?
665Yes/No? <i>y</i>
666</pre>
667
668<p>
669You can now <c>print</c> the partition layout again to validate if everything is
670as expected. When you are satisfied, use the <c>quit</c> command to exit
671<c>parted</c>.
672</p>
673
674</body>
675</subsection>
676</section>
469<section id="filesystems"> 677<section id="filesystems">
470<title>Creating Filesystems</title> 678<title>Creating Filesystems</title>
471<subsection> 679<subsection>
472<title>Introduction</title> 680<title>Introduction</title>
473<body> 681<body>

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20