This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Handbuch:MIPS/Installation/Festplatten

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:MIPS/Installation/Disks and the translation is 100% complete.
MIPS Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


Einführung in blockorientierte Geräte

Blockorientierte Geräte

Let's take a good look at disk-oriented aspects of Gentoo Linux and Linux in general, including Linux filesystems, partitions, and block devices. Once the ins and outs of disks and filesystems are understood, partitions and filesystems can be established for the Gentoo Linux installation.

To begin, let's look at block devices. The most famous block device is probably the one that represents the first drive in a Linux system, namely /dev/sda. SCSI and Serial ATA drives are both labeled /dev/sd*; even IDE drives are labeled /dev/sd* with the libata framework in the kernel. When using the old device framework, then the first IDE drive is /dev/hda.

The block devices above represent an abstract interface to the disk. User programs can use these block devices to interact with the disk without worrying about whether the drives are IDE, SCSI, or something else. The program can simply address the storage on the disk as a bunch of contiguous, randomly-accessible 512-byte blocks.


Partitionen

Obwohl es theoretisch möglich wäre eine vollständige Festplatte zu nutzen um ein Linux-System unterzubringen, kommt das in der Praxis fast nie vor. Stattdessen werden komplette Festplatten Block Devices in kleinere, besser handhabbare Block Devices unterteilt. Diese werden Partitionen genannt.

Entwurf Partitionsschema

How many partitions and how big?

The number of partitions is highly dependent on the environment. For instance, if there are lots of users, then it is advised to have /home/ separate as it increases security and makes backups easier. If Gentoo is being installed to perform as a mail server, then /var/ should be separate as all mails are stored inside /var/. A good choice of filesystem will then maximize the performance. Game servers will have a separate /opt/ as most gaming servers are installed there. The reason is similar for the /home/ directory: security and backups. In most situations, /usr/ is to be kept big: not only will it contain the majority of applications, it typically also hosts the Gentoo ebuild repository (by default located at /usr/portage) which already takes around 650 MiB. This disk space estimate excludes the packages/ and distfiles/ directories that are generally stored within this ebuild repository.

It very much depends on what the administrator wants to achieve. Separate partitions or volumes have the following advantages:

  • Choose the best performing filesystem for each partition or volume.
  • The entire system cannot run out of free space if one defunct tool is continuously writing files to a partition or volume.
  • If necessary, file system checks are reduced in time, as multiple checks can be done in parallel (although this advantage is more with multiple disks than it is with multiple partitions).
  • Security can be enhanced by mounting some partitions or volumes read-only, nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc.

Jedoch haben viele Partitionen auch Nachteile. Wenn diese schlecht auf das System angepasst sind, hat dieses viel freien Speicherplatz auf einer Partition und keinen auf einer Anderen mehr übrig. Ein weiterer Nachteil besteht darin, dass separate Partitionen - vor allem für wichtige Mount-Pfade wie /usr/ oder /var/ - es notwendig ein initramfs während des Bootens zu benutzen, welches diese Partitionen vor der Ausführung anderer Bootskripte mountet.

Weiterhin gibt es ein Limit von maximal 15 Partitionen für SCSI und SATA Datenträger, es sei denn der Datenträger nutzt GPT-labels.

What about swap space?

Die perfekte Größe für eine Swap-Partition gibt es nicht. Der Zweck von Swap-Speicher es ist Festplattenspeicherplatz für den Kernel bereitzuhalten, wenn der interne Speicher (RAM) knapp wird. Der Swap-Speicher erlaubt dem Kernel Speicherseiten auf die vermutlich nicht bald zugegriffen wird auf die Platte auszulagern (Swap oder Page-Out) um Arbeitsspeicher freizumachen. Wird der Speicherinhalt plötzlich benötigt, müssen diese Speicherseiten (Pages) wieder zurück in den Arbeitsspeicher geladen werden (Page-In), dies dauert eine Weile (da Festplatten verglichen mit Arbeitsspeicher sehr langsam sind).

When the system is not going to run memory intensive applications or the system has lots of memory available, then it probably does not need much swap space. However, swap space is also used to store the entire memory in case of hibernation. If the system is going to need hibernation, then a bigger swap space is necessary, often at least the amount of memory installed in the system.


fdisk verwenden

SGI Maschinen: SGI Plattenlabel erstellen

Alle Festplatten in einem SGI System benötigen ein SGI Plattenlabel, welches eine ähnliche Funktionalität wie ein Sun oder MS-DOS Plattenlabel bietet -- es speichert Informationen über die Partitionen einer Festplatte. Die Erzeugung eines neuen SGI Plattenlabels erzeugt zwei spezielle Partitionen auf der Festplatte:

  • SGI Volume Header (9. Partition): Diese Partition ist wichtig. Sie ist der Ort an dem sich der Bootloader befindet und in einigen Fällen enthält sie ebenfalls die Kernel-Abbilder.
  • SGI Volume (11. Partition): Diese Partition ist ähnlich wichtig wie die dritte Partition des Sun Plattenlabels "Whole Disk". Diese Partition umschließt die gesamte Festplatte und solle unberührt bleiben. Sie dient keinem anderen speziellen Zweck außer das PROM in undokumentierter Weise zu unterstützen (oder es wird irgendwie von IRIX verwendet).
Warnung
Der SGI Volume Header muss bei Zylinder 0 beginnen. Ein Fehler hierbei bedeutet ein Scheitern beim Booten von der Platte.

Das Folgende ist ein Beispiel-Auszug einer fdisk Sitzung. Lesen und passen Sie es Ihren persönlichen Bedürfnissen an ...

root #fdisk /dev/sda

Wechseln Sie in den Expertenmodus:

Command (m for help):x

Mit m wird das vollständige Menü der Optionen angezeigt:

Expert command (m for help):m
Command action
   b   move beginning of data in a partition
   c   change number of cylinders
   d   print the raw data in the partition table
   e   list extended partitions
   f   fix partition order
   g   create an IRIX (SGI) partition table
   h   change number of heads
   m   print this menu
   p   print the partition table
   q   quit without saving changes
   r   return to main menu
   s   change number of sectors/track
   v   verify the partition table
   w   write table to disk and exit

Erzeugen Sie ein SGI Plattenlabel:

Expert command (m for help):g
Building a new SGI disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content will be irrecoverably lost.

Kehren Sie zum Hauptmenü zurück:

Expert command (m for help):r

Werfen wir einen Blick auf das aktuelle Partitions-Layout:

Command (m for help):p
Disk /dev/sda (SGI disk label): 64 heads, 32 sectors, 17482 cylinders
Units = cylinders of 2048 * 512 bytes
  
----- partitions -----
Pt#     Device  Info     Start       End   Sectors  Id  System
 9:  /dev/sda1               0         4     10240   0  SGI volhdr
11:  /dev/sda2               0     17481  35803136   6  SGI volume
----- Bootinfo -----
Bootfile: /unix
----- Directory Entries -----
Notiz
Wenn die Festplatte bereits ein bestehendes SGI Plattenlabel hat, wird fdisk die Erzeugung eines neuen Labels nicht gestatten. Es gibt zwei Möglichkeiten das zu umgehen. Die erste ist die Erstellung eines Sun oder MS-DOS Plattenlabels, die Änderungen auf die Festplatte zu schreiben und fdisk neu zu starten. Die zweite ist die Partitionstabelle mit Nullwerten durch den folgenden Befehl zu überschreiben: dd if=/dev/zero of=/dev/sda bs=512 count=1

SGI Volume-Header Größenänderung

Wichtig
Diesen Schritt benötigt man aufgrund eines Bugs in fdisk oft. Aus irgendeinem Grund wird der Volume-Header nicht korrekt erstellt. Das Ergebnis ist, dass er auf Zylinder 0 startet und endet. Dies verhindert, dass mehreren Partitionen erstellt werden. Um dieses Problem zu umgehen ... lesen Sie weiter.

Da jetzt ein SGI Plattenlabel erstellt wurde, können nun Partitionen definiert werden. Im obigen Beispiel sind bereits zwei Partitionen definiert. Das sind wie erwähnt die besonderen Partitionen und sie sollten normalerweise nicht verändert werden. Wie auch immer, zur Installation von Gentoo müssen wir einen Bootloader und möglicherweise mehrere Kernel-Abbilder (abhängig vom Systemtyp) direkt in den Volume-Header laden. Der Volume-Header selbst kann bis zu acht Abbilder jeglicher Größe beinhalten mit jeweils einem acht Zeichen langen Namen.

Der Vorgang den Volume-Header größer zu machen ist etwas verworren und mit einem kleinen Trick verbunden. Man kann den Volume-Header wegen dem eigenartigen Verhalten von fdisk nicht einfach löschen und ihn dann wieder neu hinzufügen. Im Beispiel unten erzeugen wir einen 50 MB großen Volume-Header in Verbindung mit einer 50 MB großen /boot/ Partition. Das tatsächliche Plattenlayout kann sich unterscheiden, dies dient nur der Veranschaulichung.

Eine neue Partition erstellen:

Command (m for help):n
Partition number (1-16): 1
First cylinder (5-8682, default 5): 51
 Last cylinder (51-8682, default 8682): 101

Beachten Sie, dass fdisk zur Neuerstellung von Partition Nr. 1 als kleinsten Zylinder 5 gestattet. Wenn wir versucht hätten den SGI Volume-Header zu löschen und auf diese Weise wiederherzustellen, würden wir vor dem gleichen Problem stehen. In unserem Beispiel wollen wir dass /boot/ 50 MB groß ist, deshalb starten wir bei Zylinder 51. (- Der Volume-Header muss bei Zylinder 0 beginnen, erinnern Sie sich?) Den End-Zylinder setzten wir bei 101, das in etwa 50 MB entspricht (+/- 1..5 MB).

Die Partition löschen:

Command (m for help):d
Partition number (1-16): 9

Jetzt die Neuerstellung der Volume-Header Partition:

Command (m for help):n
Partition number (1-16): 9
First cylinder (0-50, default 0): 0
 Last cylinder (0-50, default 50): 50

Wenn Sie sich unsicher über die Verwendung fdisk sind, werfen sie weiter unten einen Blick auf die Anleitung zur Partitionierung auf Cobalt Systemen. Das Konzept ist genau das gleiche -- denken Sie nur daran die Volume-Header und die "Whole Disk" Partition in Ruhe zu lassen.

Sobald dies geschehen ist können Sie die übrigen Partitionen die Sie benötigen erzeugen. Nachdem Sie alle Partitionen angelegt haben, stellen Sie sicher die Partitions-ID der Swap Partition auf 82 zu stellen, "Linux Swap". Der Standard ist 83, "Linux Native".

Cobalt Festplatten partitionieren

Auf Cobalt Maschinen erwartet das BOOTROM einen MS-DOS MBR, deshalb ist die Festplattenpartitionierung relativ geradlinig. -- In der Tat wird dies wie bei einer Intel x86 Maschine gemacht. Es gibt jedoch ein paar Dinge die Sie beachten sollten.

  • Die Cobalt Firmware erwartet /dev/sda1 als Linux Partition im Format EXT2 Revision 0. EXT Revision 1 Partitionen funktionieren NICHT! (Das Cobalt BOOTROM versteht nur EXT2r0.)
  • Die oben angesprochene Partition muss das gzip-komprimierte ELF Abbild vmlinux.gz in der Wurzel ("root") dieser Partition enthalten, das als Kernel geladen wird.

Aus diesem Grund wird eine ca. 20 MB große mit EXT2r0 formatierte /boot/ Partition empfohlen auf der CoLo und die Kernel installiert werden. Dies gestattet dem Benutzer ein modernes Dateisystem (EXT3 oder ReiserFS) auf der Root Partition zu betreiben.

Im Beispiel wird davon ausgegangen, dass /dev/sda1 erzeugt wird, um später als /boot/ Partition eingehängt zu werden. Falls Sie die Partition zu / machen wollen, denken Sie an die Erwartungen des PROMs.

Also weiter ... Um die Partition zu erstellen geben Sie an der Eingabeaufforderung fdisk /dev/sda ein. Die wichtigsten Befehle, die Sie wissen sollten sind diese:

CodeWichtige fdisk Befehle

'"`UNIQ--pre-00000007-QINU`"'

This is a deprecated template. Help us update this template!

root #fdisk /dev/sda
The number of cylinders for this disk is set to 19870.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Fangen Sie damit an, alle vorhandenen Partitionen zu löschen:

Command (m for help):o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
  
  
The number of cylinders for this disk is set to 19870.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Überprüfen Sie nun durch Drücken der Befehlstaste p, dass die Partitionstabelle leer ist:

Command (m for help):p
Disk /dev/sda: 10.2 GB, 10254827520 bytes
16 heads, 63 sectors/track, 19870 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
  
   Device Boot      Start         End      Blocks   Id  System

Erstellen Sie die /boot Partition:

Command (m for help):n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-19870, default 1):
Last cylinder or +size or +sizeM or +sizeK (1-19870, default 19870): +20M

Wenn Sie die Partitionen ausgeben lassen, beachten Sie die neu erstellte:

Command (m for help):p
Disk /dev/sda: 10.2 GB, 10254827520 bytes
16 heads, 63 sectors/track, 19870 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          40       20128+  83  Linux

Lassen Sie uns nun eine erweiterte Partition erstellen, die den Rest der Festplatte umfasst. In dieser erweiterten Partition legen wir die übrigen Partitionen (logische Partitionen) an:

Command (m for help):n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (41-19870, default 41):
Using default value 41
Last cylinder or +size or +sizeM or +sizeK (41-19870, default 19870):
Using default value 19870

Jetzt erstellen wir die Partitionen /, /usr, /var usw.

Command (m for help):n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (41-19870, default 41):<Press ENTER>
Using default value 41
Last cylinder or +size or +sizeM or +sizeK (41-19870, default 19870): +500M

Wiederholen Sie dies wie benötigt.

Zum Schluss zur Swap Partition. Es wird empfohlen mindestens 250 MB, besser 1 GB Speicherplatz zu verwenden:

Command (m for help):n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (17294-19870, default 17294): <Press ENTER>
Using default value 17294
Last cylinder or +size or +sizeM or +sizeK (1011-19870, default 19870): <Press ENTER>
Using default value 19870

Wenn Sie die Partitionstabelle überprüfen, sollte alles bereit sein - bis auf eine Sache.

Command (m for help):p
Disk /dev/sda: 10.2 GB, 10254827520 bytes
16 heads, 63 sectors/track, 19870 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
  
Device Boot      Start         End      Blocks      ID  System
/dev/sda1               1          21       10552+  83  Linux
/dev/sda2              22       19870    10003896    5  Extended
/dev/sda5              22        1037      512032+  83  Linux
/dev/sda6            1038        5101     2048224+  83  Linux
/dev/sda7            5102        9165     2048224+  83  Linux
/dev/sda8            9166       13229     2048224+  83  Linux
/dev/sda9           13230       17293     2048224+  83  Linux
/dev/sda10          17294       19870     1298776+  83  Linux

Ist Ihnen aufgefallen, dass Partition 10 - die Swap Partition - immer noch vom Typ 83 ist? Lassen Sie uns das auf den richtigen Typ ändern:

Command (m for help):t
Partition number (1-10): 10
Hex code (type L to list codes): 82
Changed system type of partition 10 to 82 (Linux swap)

Nun zur Überprüfung:

Command (m for help):p
Disk /dev/sda: 10.2 GB, 10254827520 bytes
16 heads, 63 sectors/track, 19870 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
  
Device Boot      Start         End      Blocks      ID  System
/dev/sda1               1          21       10552+  83  Linux
/dev/sda2              22       19870    10003896    5  Extended
/dev/sda5              22        1037      512032+  83  Linux
/dev/sda6            1038        5101     2048224+  83  Linux
/dev/sda7            5102        9165     2048224+  83  Linux
/dev/sda8            9166       13229     2048224+  83  Linux
/dev/sda9           13230       17293     2048224+  83  Linux
/dev/sda10          17294       19870     1298776+  82  Linux Swap

Wir speichern die neue Partitionstabelle:

Command (m for help):w
The partition table has been altered!
  
Calling ioctl() to re-read partition table.
Syncing disks.


Erstellung von Dateisystemen

Einleitung

Now that the partitions are created, it is time to place a filesystem on them. In the next section the various file systems that Linux supports are described. Readers that already know which filesystem to use can continue with Applying a filesystem to a partition. The others should read on to learn about the available filesystems...

Dateisysteme

Several filesystems are available. Some of them are found stable on the mips architecture - it is advised to read up on the filesystems and their support state before selecting a more experimental one for important partitions.

btrfs
A next generation filesystem that provides many advanced features such as snapshotting, self-healing through checksums, transparent compression, subvolumes and integrated RAID. A few distributions have begun to ship it as an out-of-the-box option, but it is not production ready. Reports of filesystem corruption are common. Its developers urge people to run the latest kernel version for safety because the older ones have known problems. This has been the case for years and it is too early to tell if things have changed. Fixes for corruption issues are rarely backported to older kernels. Proceed with caution when using this filesystem!
ext2
This is the tried and true Linux filesystem but doesn't have metadata journaling, which means that routine ext2 filesystem checks at startup time can be quite time-consuming. There is now quite a selection of newer-generation journaled filesystems that can be checked for consistency very quickly and are thus generally preferred over their non-journaled counterparts. Journaled filesystems prevent long delays when the system is booted and the filesystem happens to be in an inconsistent state.
ext3
The journaled version of the ext2 filesystem, providing metadata journaling for fast recovery in addition to other enhanced journaling modes like full data and ordered data journaling. It uses an HTree index that enables high performance in almost all situations. In short, ext3 is a very good and reliable filesystem.
ext4
Initially created as a fork of ext3, ext4 brings new features, performance improvements, and removal of size limits with moderate changes to the on-disk format. It can span volumes up to 1 EB and with maximum file size of 16TB. Instead of the classic ext2/3 bitmap block allocation ext4 uses extents, which improve large file performance and reduce fragmentation. Ext4 also provides more sophisticated block allocation algorithms (delayed allocation and multiblock allocation) giving the filesystem driver more ways to optimize the layout of data on the disk. Ext4 is the recommended all-purpose all-platform filesystem.
f2fs
The Flash-Friendly File System was originally created by Samsung for the use with NAND flash memory. As of Q2, 2016, this filesystem is still considered immature, but it is a decent choice when installing Gentoo to microSD cards, USB drives, or other flash-based storage devices.
JFS
IBM's high-performance journaling filesystem. JFS is a light, fast and reliable B+tree-based filesystem with good performance in various conditions.
ReiserFS
A B+tree-based journaled filesystem that has good overall performance, especially when dealing with many tiny files at the cost of more CPU cycles. ReiserFS appears to be less maintained than other filesystems.
XFS
A filesystem with metadata journaling which comes with a robust feature-set and is optimized for scalability. XFS seems to be less forgiving to various hardware problems.
vfat
Also known as FAT32, is supported by Linux but does not support any permission settings. It is mostly used for interoperability with other operating systems (mainly Microsoft Windows) but is also a necessity for some system firmware (like UEFI).
NTFS
This "New Technology" filesystem is the flagship filesystem of Microsoft Windows. Similar to vfat above it does not store permission settings or extended attributes necessary for BSD or Linux to function properly, therefore it cannot be used as a root filesystem. It should only be used for interoperability with Microsoft Windows systems (note the emphasis on only).

When using ext2, ext3, or ext4 on a small partition (less than 8GB), then the file system must be created with the proper options to reserve enough inodes. The mke2fs (mkfs.ext2) application uses the "bytes-per-inode" setting to calculate how many inodes a file system should have. On smaller partitions, it is advised to increase the calculated number of inodes.

Bei ext2 kann dies mit dem folgenden Befehl erfolgen:

root #mkfs.ext2 -T small /dev/<device>

Bei ext3 und ext4 fügen Sie die Option -j hinzu um Journaling zu aktivieren:

root #mkfs.ext2 -j -T small /dev/<device>

Dies vervierfacht die Zahl der Inodes für ein angegebenes Dateisystem in der Regel, da es dessen "bytes-per-inode" (Bytes pro Inode) von 16 kB auf 4 kB pro Inode reduziert. Durch die Angabe des Verhältnisses kann dies sogar weiter optimiert werden:

root #mkfs.ext2 -i <ratio> /dev/<device>

Dateisystem auf Partition anlegen

To create a filesystem on a partition or volume, there are user space utilities available for each possible filesystem. Click the filesystem's name in the table below for additional information on each filesystem:

Filesystem Creation command On minimal CD? Package
btrfs mkfs.btrfs Yes sys-fs/btrfs-progs
ext2 mkfs.ext2 Yes sys-fs/e2fsprogs
ext3 mkfs.ext3 Yes sys-fs/e2fsprogs
ext4 mkfs.ext4 Yes sys-fs/e2fsprogs
f2fs mkfs.f2fs Yes sys-fs/f2fs-tools
jfs mkfs.jfs Yes sys-fs/jfsutils
reiserfs mkfs.reiserfs Yes sys-fs/reiserfsprogs
xfs mkfs.xfs Yes sys-fs/xfsprogs
vfat mkfs.vfat Yes sys-fs/dosfstools
NTFS mkfs.ntfs Yes sys-fs/ntfs3g

For instance, to have the boot partition (/dev/sda1) in ext2 and the root partition (/dev/sda5) in ext4 as used in the example partition structure, the following commands would be used:

root #mkfs.ext2 /dev/sda1
root #mkfs.ext4 /dev/sda5

Erzeugen Sie nun die Dateisysteme auf den zuvor erzeugten Partitionen (oder logischen Laufwerken).

Activating the swap partition

mkswap is the command that is used to initialize swap partitions:

root #mkswap /dev/sda10

To activate the swap partition, use swapon:

root #swapon /dev/sda10

Erzeugen und aktivieren Sie jetzt die Swap-Partition mit den oben genannten Befehlen.

Einhängen

Now that the partitions are initialized and are housing a filesystem, it is time to mount those partitions. Use the mount command, but don't forget to create the necessary mount directories for every partition created. As an example we mount the root partition:

root #mount /dev/sda5 /mnt/gentoo
Notiz
Wenn sich /tmp/ auf einer separaten Partition befinden muss, ändern Sie die Berechtigungen nach dem Einhängen folgendermaßen:
root #chmod 1777 /mnt/gentoo/tmp
Dies gilt ebenfalls für /var/tmp.

In der Anleitung wird später das Dateisystem proc (eine virtuelle Schnittstelle zum Kernel) zusammen mit anderen Kernel-Pseudodateisystemen eingehängt. Zunächst installieren wir jedoch die Gentoo Installationsdateien.