/[gentoo]/xml/htdocs/doc/en/handbook/hb-install-arm-disk.xml
Gentoo

Contents of /xml/htdocs/doc/en/handbook/hb-install-arm-disk.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Sat Sep 2 08:12:59 2006 UTC (8 years ago) by vapier
Branch: MAIN
File MIME type: application/xml
initial import of arm handbook

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

  ViewVC Help
Powered by ViewVC 1.1.20