/[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.13 Revision 1.20
1<?xml version='1.0' encoding='UTF-8'?> 1<?xml version='1.0' encoding='UTF-8'?>
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.13 2009/01/26 08:04:26 nightmorph Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml,v 1.20 2012/10/06 19:54:14 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>6.2</version> 16<version>13</version>
17<date>2009-01-09</date> 17<date>2012-10-06</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>
23<include href="hb-install-blockdevices.xml"/> 23<include href="hb-install-blockdevices.xml"/>
24</subsection> 24</subsection>
25 25
26<subsection> 26<subsection>
27<title>Partitions</title> 27<title>Partitions</title>
28<body> 28<body>
29 29
30<p> 30<p>
31Although it is theoretically possible to use a full disk to house your Linux 31Although it is theoretically possible to use a full disk to house your Linux
32system, this is almost never done in practice. Instead, full disk block devices 32system, this is almost never done in practice. Instead, full disk block devices
55</p> 55</p>
56 56
57<p> 57<p>
58A <e>logical</e> partition is a partition inside the extended partition. Their 58A <e>logical</e> partition is a partition inside the extended partition. Their
59definitions aren't placed inside the MBR, but are declared inside the extended 59definitions aren't placed inside the MBR, but are declared inside the extended
60partition. 60partition.
61</p> 61</p>
62 62
63</body> 63</body>
64</subsection> 64</subsection>
65<subsection> 65<subsection>
66<title>Advanced Storage</title> 66<title>Advanced Storage</title>
67<body> 67<body>
68 68
69<p> 69<p>
70The <keyval id="arch"/> Installation CDs provide support for EVMS and LVM2. 70The <keyval id="arch"/> Installation CDs provide support for LVM2.
71EVMS and LVM2 increase the flexibility offered by your partitioning setup. 71LVM2 increases the flexibility offered by your partitioning setup.
72During the installation instructions, we will focus on "regular" partitions, 72During the installation instructions, we will focus on "regular" partitions,
73but it is still good to know EVMS and LVM2 are supported as well. 73but it is still good to know LVM2 is supported as well.
74</p> 74</p>
75 75
76</body> 76</body>
77</subsection> 77</subsection>
78</section> 78</section>
79<section> 79<section>
80<title>Designing a Partitioning Scheme</title> 80<title>Designing a Partitioning Scheme</title>
81<subsection> 81<subsection>
82<title>Default Partitioning Scheme</title> 82<title>Default Partitioning Scheme</title>
83<body> 83<body>
84 84
85<p> 85<p>
86If you are not interested in drawing up a partitioning scheme for your system, 86If you are not interested in drawing up a partitioning scheme for your system,
87you can use the partitioning scheme we use throughout this book: 87you can use the partitioning scheme we use throughout this book:
88</p> 88</p>
106 <ti>512M</ti> 106 <ti>512M</ti>
107 <ti>Swap partition</ti> 107 <ti>Swap partition</ti>
108</tr> 108</tr>
109<tr> 109<tr>
110 <ti><path>/dev/sda3</path></ti> 110 <ti><path>/dev/sda3</path></ti>
111 <ti>ext3</ti> 111 <ti>ext3</ti>
112 <ti>Rest of the disk</ti> 112 <ti>Rest of the disk</ti>
113 <ti>Root partition</ti> 113 <ti>Root partition</ti>
114</tr> 114</tr>
115</table> 115</table>
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>
127<title>How Many and How Big?</title> 130<title>How Many and How Big?</title>
128<body> 131<body>
129 132
130<p> 133<p>
131The number of partitions is highly dependent on your environment. For instance, 134The number of partitions is highly dependent on your environment. For instance,
132if you have lots of users, you will most likely want to have your 135if 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. 136<path>/home</path> separate as it increases security and makes backups easier.
134If you are installing Gentoo to perform as a mailserver, your 137If you are installing Gentoo to perform as a mailserver, your
135<path>/var</path> should be separate as all mails are stored inside 138<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 139<path>/var</path>. A good choice of filesystem will then maximise your
154 Your entire system cannot run out of free space if one defunct tool is 157 Your entire system cannot run out of free space if one defunct tool is
155 continuously writing files to a partition or volume 158 continuously writing files to a partition or volume
156</li> 159</li>
157<li> 160<li>
158 If necessary, file system checks are reduced in time, as multiple checks can 161 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 162 be done in parallel (although this advantage is more with multiple disks than
160 it is with multiple partitions) 163 it is with multiple partitions)
161</li> 164</li>
162<li> 165<li>
163 Security can be enhanced by mounting some partitions or volumes read-only, 166 Security can be enhanced by mounting some partitions or volumes read-only,
164 nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc. 167 nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc.
165</li> 168</li>
166</ul> 169</ul>
167 170
168<p> 171<p>
169However, multiple partitions have one big disadvantage: if not configured 172However, multiple partitions have disadvantages as well. If not configured
170properly, you might result in having a system with lots of free space on one 173properly, you will have a system with lots of free space on one partition and
171partition and none on another. There is also a 15-partition limit for SCSI and 174none on another. Another nuisance is that separate partitions - especially
172SATA. 175for important mountpoints like <path>/usr</path> or <path>/var</path> - often
176require the administrator to boot with an initramfs to mount the partition
177before other boot scripts start. This isn't always the case though, so your
178results may vary.
179</p>
180
181<p>
182There is also a 15-partition limit for SCSI and SATA unless you use GPT
183labels.
173</p> 184</p>
174 185
175<p> 186<p>
176As an example partitioning, we show you one for a 20GB disk, used as a 187As an example partitioning, we show you one for a 20GB disk, used as a
177demonstration laptop (containing webserver, mailserver, gnome, ...): 188demonstration laptop (containing webserver, mailserver, gnome, ...):
178</p> 189</p>
179 190
180<pre caption="Filesystem usage example"> 191<pre caption="Filesystem usage example">
181$ <i>df -h</i> 192$ <i>df -h</i>
182Filesystem Type Size Used Avail Use% Mounted on 193Filesystem Type Size Used Avail Use% Mounted on
183/dev/sda5 ext3 509M 132M 351M 28% / 194/dev/sda5 ext3 509M 132M 351M 28% /
184/dev/sda2 ext3 5.0G 3.0G 1.8G 63% /home 195/dev/sda2 ext3 5.0G 3.0G 1.8G 63% /home
185/dev/sda7 ext3 7.9G 6.2G 1.3G 83% /usr 196/dev/sda7 ext3 7.9G 6.2G 1.3G 83% /usr
186/dev/sda8 ext3 1011M 483M 477M 51% /opt 197/dev/sda8 ext3 1011M 483M 477M 51% /opt
187/dev/sda9 ext3 2.0G 607M 1.3G 32% /var 198/dev/sda9 ext3 2.0G 607M 1.3G 32% /var
188/dev/sda1 ext2 51M 17M 31M 36% /boot 199/dev/sda1 ext2 51M 17M 31M 36% /boot
189/dev/sda6 swap 516M 12M 504M 2% &lt;not mounted&gt; 200/dev/sda6 swap 516M 12M 504M 2% &lt;not mounted&gt;
190<comment>(Unpartitioned space for future usage: 2 GB)</comment> 201<comment>(Unpartitioned space for future usage: 2 GB)</comment>
191</pre> 202</pre>
192 203
193<p> 204<p>
194<path>/usr</path> is rather full (83% used) here, but once 205<path>/usr</path> is rather full (83% used) here, but once
195all software is installed, <path>/usr</path> doesn't tend to grow that much. 206all software is installed, <path>/usr</path> doesn't tend to grow that much.
196Although allocating a few gigabytes of disk space for <path>/var</path> may 207Although allocating a few gigabytes of disk space for <path>/var</path> may
197seem excessive, remember that Portage uses this partition by default for 208seem excessive, remember that Portage uses this partition by default for
198compiling packages. If you want to keep <path>/var</path> at a more reasonable 209compiling packages. If you want to keep <path>/var</path> at a more reasonable
199size, such as 1GB, you will need to alter your <c>PORTAGE_TMPDIR</c> variable 210size, such as 1GB, you will need to alter your <c>PORTAGE_TMPDIR</c> variable
200in <path>/etc/make.conf</path> to point to the partition with enough free space 211in <path>/etc/portage/make.conf</path> to point to the partition with enough
201for compiling extremely large packages such as OpenOffice. 212free space for compiling extremely large packages such as OpenOffice.
202</p> 213</p>
203 214
204</body> 215</body>
205</subsection> 216</subsection>
206</section> 217</section>
207<section id="fdisk"> 218<section id="fdisk">
208<title>Using fdisk to Partition your Disk</title> 219<title>Using fdisk to Partition your Disk</title>
209<subsection> 220<subsection>
210<body> 221<body>
211 222
223<impo>
224If your environment will deal with partitions larger than 2 TB, please
225use the <uri link="#parted">Using parted to Partition your Disk</uri>
226instructions instead. <c>fdisk</c> is not able to deal with larger
227partitions.
228</impo>
229
212<p> 230<p>
213The following parts explain how to create the example partition layout 231The following parts explain how to create the example partition layout
214described previously, namely: 232using <c>fdisk</c>. The example partition layout was mentioned earlier:
215</p> 233</p>
216 234
217<table> 235<table>
218<tr> 236<tr>
219 <th>Partition</th> 237 <th>Partition</th>
220 <th>Description</th> 238 <th>Description</th>
221</tr> 239</tr>
222<tr> 240<tr>
223 <ti><path>/dev/sda1</path></ti> 241 <ti><path>/dev/sda1</path></ti>
224 <ti>Boot partition</ti> 242 <ti>Boot partition</ti>
225</tr> 243</tr>
226<tr> 244<tr>
227 <ti><path>/dev/sda2</path></ti> 245 <ti><path>/dev/sda2</path></ti>
228 <ti>Swap partition</ti> 246 <ti>Swap partition</ti>
229</tr> 247</tr>
454To save the partition layout and exit <c>fdisk</c>, type <c>w</c>. 472To save the partition layout and exit <c>fdisk</c>, type <c>w</c>.
455</p> 473</p>
456 474
457<pre caption="Save and exit fdisk"> 475<pre caption="Save and exit fdisk">
458Command (m for help): <i>w</i> 476Command (m for help): <i>w</i>
459</pre> 477</pre>
460 478
461<p> 479<p>
462Now that your partitions are created, you can continue with <uri 480Now that your partitions are created, you can continue with <uri
463link="#filesystems">Creating Filesystems</uri>. 481link="#filesystems">Creating Filesystems</uri>.
464</p> 482</p>
465 483
466</body> 484</body>
467</subsection> 485</subsection>
468</section> 486</section>
487<section id="parted">
488<title>Using parted to Partition your Disk</title>
489<subsection>
490<body>
491
492<p>
493In this chapter, we guide you through the creation of the example partition
494layout mentioned earlier in the instructions. Unlike the previous chapter, we
495describe the method using the <c>parted</c> application instead. Both
496<c>parted</c> and <c>fdisk</c> offer the same functions, so if you partitioned
497your system using <c>fdisk</c> already, you can skip this section and continue
498with <uri link="#filesystems">Creating Filesystems</uri>.
499</p>
500
501<p>
502The example partition layout we use is shown in the next table:
503</p>
504
505<table>
506<tr>
507 <th>Partition</th>
508 <th>Description</th>
509</tr>
510<tr>
511 <ti><path>/dev/sda1</path></ti>
512 <ti>Boot partition</ti>
513</tr>
514<tr>
515 <ti><path>/dev/sda2</path></ti>
516 <ti>Swap partition</ti>
517</tr>
518<tr>
519 <ti><path>/dev/sda3</path></ti>
520 <ti>Root partition</ti>
521</tr>
522</table>
523
524<p>
525Change your partition layout according to your own preference.
526</p>
527
528</body>
529</subsection>
530<subsection>
531<title>Viewing the Current Partition Layout</title>
532<body>
533
534<p>
535The <c>parted</c> application is a somewhat more modern variant of
536<c>fdisk</c>. It offers a simpler interface for partitioning your disks and
537supports very large partitions (more than 2 TB). Fire up <c>parted</c> on your
538disk (in our example, we use <path>/dev/sda</path>):
539</p>
540
541<pre caption="Starting parted">
542# <i>parted /dev/sda</i>
543GNU Parted 2.3
544Using /dev/vda
545Welcome to GNU Parted! Type 'help' to view a list of commands.
546</pre>
547
548<p>
549To find out about all options supported by <c>parted</c>, type <c>help</c> and
550press return. For now, we just continue by asking <c>parted</c> to show the
551partitions currently in use on the selected disk. The <c>print</c> command can
552be used for that.
553</p>
554
555<pre caption="An example partition configuration shown by parted">
556(parted) <i>print</i>
557Model: SCSI Block Device
558Disk /dev/sda: 21.5GB
559Sector size (logical/physical): 512B/512B
560Partition Table: msdos
561
562Number Start End Size Type File system Flags
563 1 512B 2148MB 2148MB primary ext4
564 2 2148MB 3222MB 1074MB primary linux-swap(v1)
565 3 3222MB 21.5GB 18.3GB primary lvm
566</pre>
567
568</body>
569</subsection>
570<subsection>
571<title>Optional: Setting the GPT Label</title>
572<body>
573
574<p>
575Most disks on x86/amd64 are prepared using an <e>msdos</e> label. However, if
576you plan on creating huge partitions (2 TB and more), you must use a <e>gpt</e>
577label (the <e>GUID Partition Type</e>) for your disk. Using <c>parted</c>, this
578can be accomplished with <c>mklabel gpt</c>:
579</p>
580
581<warn>
582Changing the partition type will remove all partitions from your disk. All data
583on the disk will be lost.
584</warn>
585
586<pre caption="Setting the GPT label">
587(parted) <i>mklabel gpt</i>
588</pre>
589
590</body>
591</subsection>
592<subsection>
593<title>Removing all Partitions</title>
594<body>
595
596<p>
597If this isn't done yet (for instance through the <c>mklabel</c> operation
598earlier, or because the disk is a freshly formatted one), we will first
599remove all existing partitions from the disk. Type <c>rm &lt;number&gt;</c>
600where &lt;number&gt; is the partition you want to remove.
601</p>
602
603<pre caption="Removing a partition from the disk">
604(parted) <i>rm 2</i>
605</pre>
606
607<p>
608Do the same for all other partitions that you don't need. However, make sure you
609do not make any mistakes here - <c>parted</c> executes the changes immediate
610(unlike <c>fdisk</c> which stages them, allowing a user to "undo" his changes
611before saving or exiting <c>fdisk</c>).
612</p>
613
614</body>
615</subsection>
616<subsection>
617<title>Creating the Partitions</title>
618<body>
619
620<p>
621Now let's create the partitions we mentioned earlier. Creating partitions with
622<c>parted</c> isn't very difficult - all we need to do is inform <c>parted</c>
623about the following settings:
624</p>
625
626<ul>
627 <li>
628 The <e>partition type</e> to use. This usually is <e>primary</e> in case you
629 are not going to have more than 4 partitions (with the <e>msdos</e>
630 partition label). Otherwise, you will need to make your fourth partition an
631 <e>extended</e> one which hosts the rest of the disk, and create
632 <e>logical</e> partitions inside it. If you use a <e>gpt</e>-labeled
633 partition, then there is no limit on the number of primary partitions.
634 </li>
635 <li>
636 The <e>file system type</e> to use. The <c>parted</c> application supports
637 most common file systems and knows which kind of partition ID it needs to
638 use for these partitions. This does <e>not</e> mean that <c>parted</c> will
639 create a file system on the partition (you can with the <c>mkpartfs</c>
640 command, but we'll use the regular <c>mkfs.*</c> commands later for this
641 purpose). The partition ID is often used by auto-detection tools to know
642 what to do with a particular partition.
643 </li>
644 <li>
645 The start location of a partition (which can be expressed in MB or GB)
646 </li>
647 <li>
648 The end location of the partition (which can be expressed in MB or GB)
649 </li>
650</ul>
651
652<p>
653One advantage of <c>parted</c> is that you can easily just use the partition
654sizes to automatically find the correct start and end location as you will see
655in the next example.
656</p>
657
658<pre caption="Creating the partitions">
659<comment># Create a 32 mbyte /boot partition</comment>
660(parted) <i>mkpart primary ext2 0 32mb</i>
661Warning: The resulting partition is not properly aligned for best performance.
662Ignore/Cancel? <i>i</i>
663
664<comment># Create a 512 mbyte swap partition</comment>
665(parted) <i>mkpart primary linux-swap 32mb 542mb</i>
666
667<comment># Create a partition that spans the remaining disk.
668# -1s (minus one s) means the end of the disk</comment>
669(parted) <i>mkpart primary ext4 542mb -1s</i>
670Warning: You requested a partition from 542MB to 21.5GB.
671The closest location we can manage is 542MB to 21.5GB.
672Is this still acceptable to you?
673Yes/No? <i>y</i>
674</pre>
675
676<p>
677You can now <c>print</c> the partition layout again to validate if everything is
678as expected. When you are satisfied, use the <c>quit</c> command to exit
679<c>parted</c>.
680</p>
681
682</body>
683</subsection>
684</section>
469<section id="filesystems"> 685<section id="filesystems">
470<title>Creating Filesystems</title> 686<title>Creating Filesystems</title>
471<subsection> 687<subsection>
472<title>Introduction</title> 688<title>Introduction</title>
473<body> 689<body>
474 690
475<p> 691<p>
476Now that your partitions are created, it is time to place a filesystem on them. 692Now that your partitions are created, it is time to place a filesystem on them.
477If you don't care about what filesystem to choose and are happy with what we use 693If you don't care about what filesystem to choose and are happy with what we use
478as default in this handbook, continue with <uri 694as default in this handbook, continue with <uri
479link="#filesystems-apply">Applying a Filesystem to a Partition</uri>. 695link="#filesystems-apply">Applying a Filesystem to a Partition</uri>.
480Otherwise read on to learn about the available filesystems... 696Otherwise read on to learn about the available filesystems...
481</p> 697</p>
482 698
483</body> 699</body>
491<title>Applying a Filesystem to a Partition</title> 707<title>Applying a Filesystem to a Partition</title>
492<body> 708<body>
493 709
494<p> 710<p>
495To create a filesystem on a partition or volume, there are tools available for 711To create a filesystem on a partition or volume, there are tools available for
496each possible filesystem: 712each possible filesystem:
497</p> 713</p>
498 714
499<table> 715<table>
500<tr> 716<tr>
501 <th>Filesystem</th> 717 <th>Filesystem</th>
502 <th>Creation Command</th> 718 <th>Creation Command</th>
503</tr> 719</tr>
504<tr> 720<tr>
505 <ti>ext2</ti> 721 <ti>ext2</ti>
506 <ti><c>mke2fs</c></ti> 722 <ti><c>mkfs.ext2</c></ti>
507</tr> 723</tr>
508<tr> 724<tr>
509 <ti>ext3</ti> 725 <ti>ext3</ti>
510 <ti><c>mke2fs -j</c></ti> 726 <ti><c>mkfs.ext3</c></ti>
727</tr>
728<tr>
729 <ti>ext4</ti>
730 <ti><c>mkfs.ext4</c></ti>
511</tr> 731</tr>
512<tr> 732<tr>
513 <ti>reiserfs</ti> 733 <ti>reiserfs</ti>
514 <ti><c>mkreiserfs</c></ti> 734 <ti><c>mkreiserfs</c></ti>
515</tr> 735</tr>
516<tr> 736<tr>
517 <ti>xfs</ti> 737 <ti>xfs</ti>
518 <ti><c>mkfs.xfs</c></ti> 738 <ti><c>mkfs.xfs</c></ti>
519</tr> 739</tr>
520<tr> 740<tr>
521 <ti>jfs</ti> 741 <ti>jfs</ti>
522 <ti><c>mkfs.jfs</c></ti> 742 <ti><c>mkfs.jfs</c></ti>
523</tr> 743</tr>
524</table> 744</table>
525 745
526<p> 746<p>
527For instance, to have the boot partition (<path>/dev/sda1</path> in our 747For instance, to have the boot partition (<path>/dev/sda1</path> in our
528example) in ext2 and the root partition (<path>/dev/sda3</path> in our example) 748example) in ext2 and the root partition (<path>/dev/sda3</path> in our example)
529in ext3 (as in our example), you would use: 749in ext3 (as in our example), you would use:
530</p> 750</p>
531 751
532<pre caption="Applying a filesystem on a partition"> 752<pre caption="Applying a filesystem on a partition">
533# <i>mke2fs /dev/sda1</i> 753# <i>mkfs.ext2 /dev/sda1</i>
534# <i>mke2fs -j /dev/sda3</i> 754# <i>mkfs.ext3 /dev/sda3</i>
535</pre> 755</pre>
536 756
537<p> 757<p>
538Now create the filesystems on your newly created partitions (or logical 758Now create the filesystems on your newly created partitions (or logical
539volumes). 759volumes).
540</p> 760</p>
541 761
542</body> 762</body>
543</subsection> 763</subsection>
544<subsection> 764<subsection>
545<title>Activating the Swap Partition</title> 765<title>Activating the Swap Partition</title>
546<body> 766<body>
547 767
548<p> 768<p>
549<c>mkswap</c> is the command that is used to initialize swap partitions: 769<c>mkswap</c> is the command that is used to initialize swap partitions:

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20