Mkinitcpio: Unterschied zwischen den Versionen

Aus wiki.archlinux.de
K (ok, auf deutsch: SEITENTITEL)
(HOOKS Infos vervollständigt)
(22 dazwischenliegende Versionen von 6 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
{{SEITENTITEL:mkinitcpio}}{{righttoc}}{{Unvollständig}}
{{SEITENTITEL:mkinitcpio}}{{righttoc}}
= Einleitung =
= Einleitung =
'''mkinitcpio''' ist die nächste Generation der '''initramfs'''-Erstellung. Es hat viele Vorteile gegenüber den alten Skripten '''mkinitrd''' und '''mkinitramfs'''.
'''mkinitcpio''' ist die nächste Generation der '''initramfs'''-Erstellung. Es hat viele Vorteile gegenüber den alten Skripten '''mkinitrd''' und '''mkinitramfs'''.
Zeile 12: Zeile 12:
'''mkinitcpio''' wurde von '''phrakture''' und '''tpowa''' mit einiger Hilfe von der Community entwickelt.
'''mkinitcpio''' wurde von '''phrakture''' und '''tpowa''' mit einiger Hilfe von der Community entwickelt.


= Installation von mkinitcpio =
= Installation =
== Aus dem current Repository ==
mkinitcpio ist Bestandteil jeder Arch Linux Installation.
Das '''mkinitcpio''' Script ist im core Repository verfügbar. Du kannst es mit [[pacman]] installieren:
# pacman -Sy mkinitcpio


== Aus dem svn ==
= Konfiguration =
Die aktuelle Entwickler-Version von '''mkinitcpio''' kannst Du aus  phraktures svn Repository laden:
Die Datei <code>/etc/mkinitcpio.conf</code> editieren, um die Standardeinstellungen zu ändern.
# svn co http://phraktured.net/initramfs
Die neuesten Scripte befinden sich nun im '''initramfs/mkinitcpio''' Verzeichnis.


= Aktivierung für Kernel ab 2.6.17 =
== MODULES ==
Es werden zwei Images während der Installation des Kernels erstellt:


- '''kernel26'''
Mit dem MODULES-Eintrag können Module explizit dem Image hinzugefügt werden.
/boot/kernel26.img --> enhält nur die automatisch erkannten Module
/boot/kernel26-fallback.img --> enthält alle Module
- '''kernel26beyond'''
/boot/kernel26beyond.img --> enhält nur die automatisch erkannten Module
/boot/kernel26beyond-fallback.img --> enthält alle Module
Ändere Deine Bootloader-Konfiguration Deinen Bedürfnissen entsprechend.
Achtung: '''lvm2''', '''raid''' and '''encrypt''' werden standardmäßig '''nicht''' aktiviert! Zur Konfiguration dieser System lese bitte die entsprechenden Anleitungen im Wiki.


= Anpassung der Konfigurations-Dateien =
Beispiel: Bei Verwendung des nouveau Treiber wird bereits die Konsole beim Starten diesen verwenden.
== '''Änderung des Haupt-Abbildes''' ==
Um die Standard-Einstellungen des Haupt-Abbild zu ändern, nutze folgende Datei:


  /etc/mkinitcpio.conf
  MODULES="nouveau"


mkinitcpio benutzt standardmäßig diese Datei.
== BINARIES und FILES ==


== '''Änderung des Rettungs-Abbild''' ==
Mit diesen Optionen können Dateien dem Abbild hinzugefügt werden. Der einzige Unterschied zwischen BINARIES und FILES ist, dass BINARIES die Bibliotheken nach Abhängigkeiten durchsucht, während FILES nur Dateien hinzufügt.
Um die Standard-Einstellungen des Rettungs-Abbild zu ändern, nutze folgende Dateien:
 
  kernel26 --> '/boot/mkinitcpio-kernel26.conf'
== HOOKS ==
  kernel26beyond --> '/boot/mkinitcpio-kernel26beyond.conf
 
und füge die Dateien der Zeile '''NoUpgrade =''' der '/etc/pacman.conf' hinzu. Dies ist nur bei speziellen Konfigurationen mit lvm oder raid nötig.
Dies ist der wichtigste Teil der mkinitcpio Konfiguration. Diese Zeile enthält alle HOOKS, welche während der Imageerstellung oder zur Laufzeit ausgeführt werden. Hierbei muss die Reihenfolge beachtet werden:
 
  HOOKS="foo1 foo2 bar1 bar2"
 
Am besten man prüft anhand des eigenen Systems, welche HOOKS aktuell verfügbar sind. Zusätzlich wird angezeigt, welche als veraltet gelten, und welche zukünftig verwendet werden sollen.
 
  mkinitcpio -L


== Konfiguration der HOOKS ==
Für jeden gelisteten HOOK gibt es eine Zusatzinfo.
Dies ist der wichtigste Teil der mkinitcpio Konfiguration. Die HOOKS Zeile enthält alle hooks die während der Abbild-Erstellung oder zur Laufzeit ausgeführt werden. Hierbei wird die Reihenfolge beachtet:


  HOOKS="foo1 foo2 foo3 bar1 bar2"
  mkinitcpio -H base


=== Verfügbare Hooks ===
=== Verfügbare HOOKS ===
{| border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border-style:solid; border-width:1px; border-collapse:collapse; empty-cells:show"
{| border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border-style:solid; border-width:1px; border-collapse:collapse; empty-cells:show"
|-
|-
! Hook || Installation || Laufzeit
! Hook || Information
|-
|-
| '''base''' || Richtet alle Basisverzeichnisse ein und installiert die Kklibctools und Bibliotheken. Füge diesen Hook immer hinzu, außer du weisst was du tust. ||
| '''base''' || This hook provides crucial runtime necessities for booting. DO NOT remove this hook unless you know what you're doing.  
|-
|-
| '''udev''' || Fügt '''udev''' zum Abbild hinzu || '''Udev''' wird genutzt um das Rootgerät zu erkennen und es ermittelt alle benötigten Module für das Rootgerät. Da es die Sache vereinfacht, wird die Nutzung des '''Udev''' Hook empfohlen.
| '''udev''' || This hook will use udev to create your root device node and detect the needed modules for your root device. It is also required for firmware loading in initramfs. It is recommended to use this hook.  
|-
|-
| '''modload''' || || Eine Alternative zu Udev die sehr viel langsamer ist. Dieser Hook ist veraltet, nutze deshalb Udev.
| '''systemd''' || This will install a basic systemd setup in your initramfs, and is meant to replace the 'base', 'usr', 'udev' and 'timestamp' hooks. Other hooks with runtime components will need to be ported, and will not work as intended. You also may wish to still include the 'base' hook (before this hook) to ensure that a rescue shell exists on your initramfs.  
|-
|-
| '''autodetect''' || Verkleinert dein Initramfs indem es die nötigen Module erkennt. Sei sicher, dass die eingetragenen Module richtig sind und keins vergessen wurde. Dieser Hook muss vor den anderen Subsystemhooks laufen um die Autoerkennung nutzen zu können. Alle Hooks vor '''autodetect''' werden voll installiert. ||
| '''modconf''' || This hook installs modprobe configuration files from /etc/modprobe.d and /usr/lib/modprobe.d.  
|-
|-
| '''ide''' || Fügt die IDE-Module zum Abbild hinzu. Nutze diesen Hook wenn die Rootpartition auf einer IDEfestplatte ist. Nutze auch den '''autodetect''' Hook wenn du die Größe deines Abbildes verringern willst. || Lädt die IDE-Module. Du brauchst den '''udev''' oder '''modload''' Hook wenn du die Module nicht manuell angibst.
| '''usr''' || This provides a support for mounting /usr via a late running hook. No configuration is needed, as the mount options will be pulled directly from the fstab on the real root device.  
|-
|-
| '''sata''' || Fügt die Sata-Module zum Abbild hinzu. Nutze '''sata''' wenn die Rootpartition auf einer Satafestplatte liegt. Nutze auch den '''autodetect''' Hook wenn du die Größe deines Abbildes verringern willst. || Lädt die Sata-Module. Du benötigst den '''udev''' oder '''modload''' Hook solange du nicht die Module manuell angibst.
| '''autodetect''' || This hook shrinks your initramfs to a smaller size by autodetecting the needed modules. Be sure to verify included modules are correct and none are missing. This hook must be run before other subsystem hooks in order to take advantage of auto-detection. Any hooks placed before 'autodetect' will be installed in full.  
|-
|-
| '''scsi''' || Fügt die SCSI Module zum Abbild hinzu. Nutze dies wenn deine Rootpartition auf einer SCSI-Platte ist. Nutze außerdem den '''autodetect''' Hook wenn du die Größe deines Abbildes verringern willst. || Lädt SCSI-Module. Du brauchst den '''udev''' oder '''modload''' Hook solange du nicht die nötigen Module manuell angibst.
| '''sata''' || This hook is deprecated in favor of 'block'  
|-
|-
| '''usb''' || Fügt die Usb-Module zum Abbild hinzu. Nutze dies wenn deine Rootpartition auf einer Usb-Platte liegt. || Lädt die Usbmodule. Du brauchst den '''udev''' oder '''modload''' Hook solange du nicht die nötigen Module manuell angibst.
| '''scsi''' || This hook is deprecated in favor of 'block'  
|-
|-
| '''usbinput''' || Fügt Usb HID Module zum Abbild hinzu. Nutze dies, wenn du deine Usbtastatur hast und diese früh benötigst (zum Beispiel zur Passworteingabe oder für den Failsafemodus). || Lädt die Usb HID Module. Du brauchst den '''udev''' oder '''modload''' Hook solange du nicht die nötigen Module manuell angibst.
| '''usb''' || This hook is deprecated in favor of 'block'  
|-
|-
| '''fw''' || Fügt die Firewire Module zum Abbild hinzu. Nutze dies, wenn deine Rootpartition auf einem Firewirespeichermedium installiert ist. || Lädt die FW Module. Du brauchst den '''udev''' oder '''modload''' Hook solange du nicht die nötigen Module manuell angibst.
| '''fw''' || This hook is deprecated in favor of 'block'  
|-
|-
| '''net''' || Fügt die notwendigen Module für Netzwerkgeräte hinzu. Für pcmcia Netzwerkgeräte füge auch den '''pcmcia''' Hook hinzu. ||  Lädt die Netzwerkmodule. Du brauchst den '''udev''' oder '''modload''' Hook solange du nicht die nötigen Module manuell angibst. Siehe [[Kernelzeile_anpassen]] für weitere Informationen.
| '''block''' || This hook loads the necessary modules for most block devices using pata, sata, scsi, firewire, usb, or mmc. Detection will take place at runtime. To minimize the modules in the image, add the autodetect hook too.  
|-
|-
| '''pcmcia''' || Fügt die Module für pcmcia zum Abbild hinzu. Du musst pcmciautils installiert haben um dies zu nutzen.|| Lädt die pcmcia Module. Du brauchst den '''udev''' oder '''modload''' Hook solange du nicht die nötigen Module manuell angibst.
| '''usbinput''' || This hook is deprecated in favor of 'keyboard'  
|-
|-
| '''dsdt''' || Lädt ein angepasstes acpi dsdt file während dem Boot. Speichere deine modifizierte  dsdt Datei dort: /lib/initcpio/custom.dsdt || Die modifizierte dsdt Datei wird automatisch vom Kernel benutzt wenn es im Initramfs vorhanden ist.
| '''keyboard''' || This hook loads the necessary modules for keyboard devices. As a side-effect modules for some non-keyboard input devices might be added to, but this should not be relied on. Detection will take place at runtime. To minimize the modules in the image, add the autodetect hook too.  
|-
|-
| '''filesystems''' || Das bindet notwendige Dateisystemmodule ins Abbild ein. Dieser Hook ist notwendig wenn du in der Lage sein willst zu booten. || Dies wird die Dateisystemtypen zur Laufzeit erkennen, lädt die Module und leitet es an kinit weiter.
| '''filesystems''' || This hook adds filesystems modules to the image. If you would like to minimize the modules installed in the image, add the autodetect hook too.  
Anmerkung: es wird nicht reiser4 erkennen, das Module muss über die Modulliste geladen werden.
|-
|-
| '''lvm2''' || Fügt das Device Mapper Kernelmodul und das LVMtool zum Abbild hinzu. Du musst das lvm2 Paket installiert haben um es zu nutzen. || Aktiviert alle lvm2 Gerätegruppen. Das ist notwendig wenn das Rootdateisystem auf einem lvm ist.
| '''lvm2''' || This hook enables LVM2 volumes in initramfs. Do pacman -S lvm2 before.  
|-
|-
| '''mdadm''' || Fügt das Modul und mdassamble für Raids hinzu. Du musst mdadm installiert haben um das Nutzen zu können. -- Enthält einen effektiveren Lademechanismus und ersetzt deswegen den Hook '''raid''' (ab Kernel 2.6.29). || Lädt die nötigen Module für Software Raid Geräte und bindet sie ein.  Die direkte Verwendung der Einstellungen der Datei /etc/mdadm.conf bewirkt, dass nur noch das root-Device in der Kernelzeile angegeben zu werden braucht. Siehe [[Kernelzeile_anpassen]] für weitere Informationen.
| '''sd-lvm2''' || This hook enables LVM2 volumes in systemd-based initramfs. Do pacman -S lvm2 before.  
|-
|-
| '''raid''' || Fügt das Modul und mdassamble für Raids hinzu. Du musst mdadm installiert haben um das Nutzen zu können.|| Lädt die nötigen Module für Software Raid Geräte und bindet sie ein. Siehe [[Kernelzeile_anpassen]] für weitere Informationen.
| '''mdadm''' || This hook loads the necessary modules for any raid root device, and assembles the raid device when run. If arrays are defined in /etc/mdadm.conf, the file will be used instead of command line assembling. Do pacman -S mdadm before. Please see mkinitcpio -H mdadm
|-
|-
| '''encrypt''' || Fügt das dm-crypt Kernelmodul und das Cryptsetuptool zum Image hinzu. Du musst das Cryptsetup Paket installiert haben. || Erkennt und entschlüsselt Rootpartitionen. Siehe [[Kernelzeile_anpassen]] für weitere Informationen.
| '''dmraid''' || This hook loads the necessary modules for a dmraid root device. Do pacman -S dmraid before.  
|-
|-
| '''resume''' || || Nötig um aus dem "suspend to disk" aufzuwachen. Arbeitet mit swsusp und [[Suspend to Disk|suspend2]]. Siehe [[Kernelzeile_anpassen]] für weitere Informationen.
| '''encrypt''' || This hook allows for an encrypted root device. Users should specify the device to be unlocked using 'cryptdevice=device:dmname' on the kernel command line, where 'device' is the path to the raw device, and 'dmname' is the name given to the device after unlocking, and will be available as /dev/mapper/dmname. Do pacman -S cryptsetup before. Please see mkinitcpio -H encrypt
|-
|-
| '''firmware''' || Fügt die Dateien aus /lib/firmware hinzu. || Lädt die Firmware. Um die Firmware zu laden wird der '''udev''' Hook benötigt.  
| '''sd-encrypt''' || This hook allows for an encrypted root device. Users should specify the device to be unlocked using 'cryptdevice=device:dmname' on the kernel command line, where 'device' is the path to the raw device, and 'dmname' is the name given to the device after unlocking, and will be available as /dev/mapper/dmname. Do pacman -S cryptsetup before. Please see mkinitcpio -H sd-encrypt
|-
|-
| '''keymap''' || Liest die Keymap und die Konsolenfont aus der rc.conf. || Lädt die spezifische Keymap und Konsolenfont aus der rc.conf.
| '''resume''' || This hook initializes support for resuming from Disk. Supports swsusp and suspend2.
|-
| '''fschk''' || This hook provides fsck and filesystem specific helpers to perform an fsck operation on the root device prior to mounting. If the autodetect hook is used, only the fsck helper specific to your filesystem will be added to the image. It is highly recommended that if you include this hook that you also include any necessary modules to ensure your keyboard will work in early userspace. Please see mkinitcpio -H fsck
|-
| '''consolefont''' || This hook loads consolefont specified in vconsole.conf during early userspace.  
|-
| '''sd-vconsole''' || This hook adds the keymap(s) and font specified in vconsole.conf to the image and loads them during early userspace.  
|}
|}


=== Beispiele ===
Beispiele:
 
Diese Konfiguration sollte für die meisten Benutzer funktionieren:
Diese Konfiguration sollte für die meisten Benutzer funktionieren:


  HOOKS="base udev autodetect ide scsi sata filesystems"
  HOOKS="base systemd autodetect modconf block filesystems sd-vconsole fsck"


Möchtest Du das Abbild auf mehr als einer Maschine nutzen, so benutze folgende Konfiguration:
Du kannst verschlüsselte Dateisysteme innerhalb von lvm nutzen:


  HOOKS="base udev ide scsi sata filesystems"
  HOOKS="base autodetect modconf block lvm2 encrypt filesystems keyboard consolefont fsck"


Du kannst verschlüsselte Dateisystem innerhalb von lvm nutzen:
Du kannst verschlüsselte Dateisysteme innerhalb von lvm nutzen, wenn systemd im Einsatz ist:


  HOOKS="base udev autodetect ide scsi sata lvm2 encrypt filesystems"
  HOOKS="base systemd autodetect modconf block sd-lvm2 sd-encrypt filesystems sd-vconsole fsck"


== Konfiguration der Module ==
== COMPRESSION ==
Mit dem MODULES-Eintrag kannst Du Module explizit laden bevor andere Aufrufe geschehen. Falls Du zum Beispiel nicht '''udev''' oder '''modload''' benutzen möchtest, kannst Du alle nötigen Module hier eintragen und so den Startvorgang etwas beschleunigen:
# Use this to compress the initramfs image. By default, gzip compression is used. Use 'cat' to create an uncompressed image.
COMPRESSION="xz"
== COMPRESSION_OPTIONS ==
# Additional options for the compressor
COMPRESSION_OPTIONS="-9"


MODULES="piix ide_disk reiserfs"
= Erstellen des Images =
HOOKS="base autodetect ide filesystems"


== Konfigurieren der BINARIES und FILES ==
Mit diesen Optionen können Dateien dem Abbild hinzugefügt werden. Der einzige Unterschied zwischen BINARIES und FILES ist, dass BINARIES die Bibliotheken nach Abhängigkeiten durchsucht, während FILES nur Dateien hinzufügt.
Beispiel:
FILES="/etc/modprobe.d/modprobe.conf"
BINARIES="/usr/bin/somefile"
= Erstellen des Images =
Erstelle das Image mit folgendem Befehl:
Erstelle das Image mit folgendem Befehl:


  mkinitcpio -g /boot/kernel26.img
  # mkinitcpio -p linux


Das wird das Image für den aktuell laufenden Kernel erstellen und als '''/boot/kernel26.img''' abspeichern.
= Extrahieren des Images =


Wenn das Image für einen anderen, als den aktuell laufenden Kernel erstellt werden soll, füge dem Befehl die Kernelversion hinzu:
Wenn du wissen möchtest, was sich innerhalb des initrd-Abbildes befindet, kann du es auspacken und in den enthaltenen Dateien herumstöbern.


mkinitcpio -g /boot/kernel26.img -k 2.6.16-ARCH
Das initrd-Abbild ist ein 'SVR4 CPIO'-Archiv, das durch die Befehle ''find'' und ''bsdcpio'' erstellt wurde und optional durch ein vom Kernel verstandenes Komprimierungsschema komprimiert wurde: genauer gesagt gzip, bzip2, lzma, lzo oder xz.


mkinitcpio beinhaltet ein Werkzeug namens lsinitcpio, welches die Inhalte des initramfs-Abbildes anzeigt und extrahiert.


''Notiz:'' Das Folgende könnte verwirrend wirken. Es ist nur für Leute interessant die Rescue Images erstellen möchten während der Kernel im Einsatz ist. Um Images für jeden Kernel zu erstellen der Momentan nicht läuft, muss die -k Option benutzt werden.
Das Anzeigen der Dateien im Abbild geschieht durch:


Ein Rescue Image sollte erstellt worden sein, als '''kernel26''' oder '''<kernel26''' installiert wurden aber falls du es neu generieren willst:
$ lsinitcpio /boot/initramfs-linux.img


mkinitcpio -c /boot/mkinitcpio-kernel26.conf -g /boot/kernel26.img
Man kann sich auch eine Auflistung der wichtigen Teile des Abbildes anzeigen lassn:


<kernel26
  $ lsinitcpio -a /boot/initramfs-linux.img
  mkinitcpio -c /boot/mkinitcpio-kernel26beyond.conf -g /boot/kernel26beyond.img


Siehe '''mkinitcpio -h''' für mehr Optionen.
Das Extrahieren aller Dateien in das aktuelle Verzeichnis:


Vergiss nicht einen neuen Bootladereintrag anzulegen. Mach einfach eine Kopie des alten und ändere den Initrd für das neue Image.
$ lsinitcpio -x /boot/initramfs-linux.img


= Kernelzeile anpassen =
= Kernelzeile anpassen =
Einige Optionen müssen in der Kernelzeile angegeben werden. Einige Mkinitcpio Hooks haben spezielle Optionen. Um diese soll es in diesem Abschnitt gehen.
Einige Optionen müssen in der Kernelzeile angegeben werden. Einige Mkinitcpio Hooks haben spezielle Optionen. Um diese soll es in diesem Abschnitt gehen.


Wenn du nicht weißt was die Kernelzeile ist, schau in die Dokumentationen von [[Grub]] oder [[Lilo]].
Wenn du nicht weißt was die Kernelzeile ist, schau in die Dokumentationen von [[GRUB]] oder [[Syslinux]].


== Failsafe Modus ==
== Failsafe Modus ==
Wenn du
Wenn du
  break=y
  break=y
zur Kernelzeile hinzufügst, dann stoppt Init nach dem das Setup vollständig ist und du landest in einer ''dash'' shell. Diese kann genutzt werden um sich über den Erfolg des Vorgangs zu versichern. Wenn du dich ausloggst geht der normale Bootvorgang weiter.
zur Kernelzeile hinzufügst, dann stoppt Init nach dem das Setup vollständig ist und du landest in einer ''dash'' shell. Diese kann genutzt werden um sich über den Erfolg des Vorgangs zu versichern. Wenn du dich ausloggst geht der normale Bootvorgang weiter.


== Hooks deaktivieren ==
== Hooks deaktivieren ==
Du kannst hooks deaktivieren in dem du ''disablehooks'' zur Kernelzeile hinzufügst:
 
Du kannst hooks deaktivieren indem du ''disablehooks'' zur Kernelzeile hinzufügst:


  disablehooks=hook1,hook2,hook2
  disablehooks=hook1,hook2,hook2
Zeile 176: Zeile 170:


== Module blacklisten ==
== Module blacklisten ==
Du kannst Module blacklisten indem du ''disablemodules'' zur Kernelzeile hinzufügst:
Du kannst Module blacklisten indem du ''disablemodules'' zur Kernelzeile hinzufügst:


Zeile 184: Zeile 179:
  disablemodules=ata_piix
  disablemodules=ata_piix


'''Diese Funktion ist seit Mkinitcpio 0.5.1 verfügbar'''
= Weitere Infos =
 
== raid nutzen ==
Füge als erstes '''raid''' zur HOOKS-liste in /etc/mkinitcpio.conf hinzu.
 
'''Kernel Parameter: '''
Definiere alle deine md Arrays mit dem md -parameter: (es reicht nur das Raid array hinzuzufügen von dem gebootet wird)
 
füge folgendes zur Kernelzeile in grub/menu.lst hinzu:
  Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1
  Beispie: kernel /vmlinuz26beyond root=/dev/md0 ro md=0,/dev/sda1,/dev/sdb1
Das definiert 2 md Arrays mit persistenten Superblöcken.
 
'''Setup:'''
  - für alte Raid Arrays ohne persistenten Superblock:
    md=<md device no.>,<raid level>,<chunk size factor>,<fault level>,dev0,dev1
  - für Raid Arrays mit persistentem Superblock:
    md=<md device no.>,dev0,dev1,...,devn
  - für partitionierte Arrays:
    md=d<md device no.>,dev0,dev1,...,devn
 
'''Parameter:'''
  - <md device no.> = die Zahl der md Geräte:
    0 bedeutet md0, 1 bedeutet md1, ...
  - <raid level> = -1 linear Modus, 0 striped Modus
    andere Modi sind nur mit persistentem Superblock verfügbar
  - <chunk size factor> = (raid-0 and raid-1 only):
    Chunk Größe auf 4k << n setzen.
  - <fault level> = Total ignorieren
  - <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1
 
''Aktuelle Änderung:'' Bei Benutzung des neuen Hooks '''mdadm''' (ab Kernel 2.6.29) anstatt von '''raid''' ist die  explizite Angabe der Raidarrays in der Kernelzeile hinfällig -- nur noch das root-Device muss angegeben werden, etwa:
  Beispiel: kernel /vmlinuz26 root=/dev/md0 ro
Die HOOKS-Zeile in der /etc/mkinitcpio.conf sieht dann bspw. so aus, wenn man von einem verschlüsselten Raid-System booten will:
  HOOKS="base udev autodetect mdadm pata scsi encrypt filesystems"
 
== Using net ==
'''Kernel Parameters:'''
 
'''ip='''
 
An interface spec can be either short form, which is just the name of
an interface (eth0 or whatever), or long form.  The long form consists
of up to seven elements, separated by colons:
 
  ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
  nfsaddrs= is an alias to ip= and can be used too.
 
''Parameter explanation:''
  <client-ip>  IP address of the client. If empty, the address will
                either be determined by RARP/BOOTP/DHCP. What protocol
                is used de- pends on the <autoconf> parameter. If this
                parameter is not empty, autoconf will be used.
 
  <server-ip>  IP address of the NFS server. If RARP is used to
                determine the client address and this parameter is NOT
                empty only replies from the specified server are
                accepted. To use different RARP and NFS server,
                specify your RARP server here (or leave it blank), and
                specify your NFS server in the `nfsroot' parameter
                (see above). If this entry is blank the address of the
                server is used which answered the RARP/BOOTP/DHCP
                request.
 
  <gw-ip>      IP address of a gateway if the server is on a different
                subnet. If this entry is empty no gateway is used and the
                server is assumed to be on the local network, unless a
                value has been received by BOOTP/DHCP.
 
  <netmask>    Netmask for local network interface. If this is empty,
                the netmask is derived from the client IP address assuming
                classful addressing, unless overridden in BOOTP/DHCP reply.
 
  <hostname>    Name of the client. If empty, the client IP address is
                used in ASCII notation, or the value received by
                BOOTP/DHCP.
 
  <device>      Name of network device to use. If this is empty, all
                devices are used for RARP/BOOTP/DHCP requests, and the
                first one we receive a reply on is configured. If you
                have only one device, you can safely leave this blank.
 
  <autoconf> Method to use for autoconfiguration. If this is either
                'rarp', 'bootp', or 'dhcp' the specified protocol is
                used.  If the value is 'both', 'all' or empty, all
                protocols are used.  'off', 'static' or 'none' means
                no autoconfiguration.
''Examples:''
  ip=127.0.0.1:::::lo:none  --> Enable the loopback interface.
  ip=192.168.1.1:::::eth2:none --> Enable static eth2 interface.
  ip=:::::eth0:dhcp --> Enable dhcp protcol for eth0 configuration.
'''nfsroot='''
 
If the 'nfsroot' parameter is NOT given on the command line, the default
"/tftpboot/%s" will be used.
 
  nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
 
''Parameter explanation:''
 
  <server-ip>  Specifies the IP address of the NFS server. If this field
                is not given, the default address as determined by the
                `ip' variable (see below) is used. One use of this
                parameter is for example to allow using different servers
                for RARP and NFS. Usually you can leave this blank.
 
  <root-dir>    Name of the directory on the server to mount as root. If
                there is a "%s" token in the string, the token will be
                replaced by the ASCII-representation of the client's IP
                address.
 
  <nfs-options> Standard NFS options. All options are separated by commas.
                If the options field is not given, the following defaults
                will be used:
                        port            = as given by server portmap daemon
                        rsize          = 1024
                        wsize          = 1024
                        timeo          = 7
                        retrans        = 3
                        acregmin        = 3
                        acregmax        = 60
                        acdirmin        = 30
                        acdirmax        = 60
                        flags          = hard, nointr, noposix, cto, ac
 
'''root=/dev/nfs'''
  If you don't use nfsroot= parameter you need to set root=/dev/nfs
  to boot from a nfs root by autoconfiguration.
 
== Using lvm ==
If your root device is on lvm, you have to add the '''lvm2''' hook. You have to pass your root device on the kernel command line in the format
 
root=/dev/mapper/<volume group name>-<logical volume name>
 
for exmaple
 
root=/dev/mapper/myvg-root
 
== Using encrypted root ==
If your root volume is encrypted, you need to add the '''encrypt''' hook. Then specify your root device on the kernel command line, just as if it was unencrypted, for example
 
root=/dev/sda5
 
for an encrypted partition on an sata or scsi disk or
 
cryptdevice=/dev/sda5:root root=/dev/mapper/root
 
for an encrypted lvm volume. The root device will be automatically changed to ''/dev/mapper/root''.
 
=== Using LUKS volumes ===
If you use LUKS for hard disk encryption, the init script will detect the encryption automatically if the '''encrypt''' hook is enabled. It will then ask for a passphrase and try to unlock the volume.
 
=== Using legacy cryptsetup volumes ===
If you are using a legacy cryptsetup volume, you have to specify all cryptsetup options necessary to unlock it on the kernel command line. The option format is
 
crypto=hash:cipher:keysize:offset:skip
 
representing cryptsetup's --hash, --cipher, --keysize, --offset and --skip options. If you omit an option, cryptsetup's default value is used, so you can just specify
 
crypto=::::
 
if you created your volume with the default settings.
 
'''NOTE:''' For technical reasons, it is not possible to verify the correctness of your passphrase with legacy cryptsetup volumes. If you typed it wrong, mounting will simply fail. It is recommended that you use LUKS instead.
 
=== Using loop-aes volumes ===
'''mkinitcpio''' does not support loop-aes yet.
 
== Using Suspend to Disk ==
If you want to use suspend to disk, you have to add the '''resume''' hook.
 
=== swsusp ===
''TODO''
 
=== µswsusp ===
µswsusp is not supported yet.
 
=== suspend2 ===
If you are using [[Suspend to Disk|suspend2]], you have to specify the ''resume2'' kernel commandline option. If you are using the swap writer, use
 
resume2=swap:/dev/hda3
 
where ''/dev/hda3'' is your swap partition. If you want to use the filewriter, use
 
resume2=file:/dev/hda2:0x123456
 
where ''/dev/hda2'' is the partition where the suspend2 image is stored (most likely the root partition) and ''0x123456'' is the file offset. You can get the exact value with the commands
 
echo "/suspend2_file" > /proc/suspend2/filewriter_target
cat /proc/suspend2/resume2
 
where /suspend2_file is the path to your suspend image file. This - of course - works for lvm volumes as well. You can also use a suspend file on an encrypted root partition with the option
 
resume2=file:/dev/mapper/root:0x123456
 
where ''0x123456'' is the offset again. Resuming from an encrypted swap partition is not supported.
 
== Example bootloader configuration files ==
If you use the beyond kernel, the filenames are ''kernel26beyond.img'' and ''kernel26beyond-fallback.img'' instead of ''kernel26.img'' and ''kernel26-fallback.img'', respectively. Also, change "vmlinuz26" to "vmlinuz26beyond".
 
=== GRUB ===
For those who have /boot on a separate partition:
 
# (0) Arch Linux
title Arch Linux
root  (hd0,3)
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro
initrd /kernel26.img
title Arch Linux Fallback
root  (hd0,3)
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro
initrd /kernel26-fallback.img
 
For those who do _not_ have /boot on a separate partition:
 
# (0) Arch Linux
title Arch Linux
root  (hd0,3)
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro
initrd /boot/kernel26.img
title Arch Linux Fallback
root  (hd0,3)
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro
initrd /boot/kernel26-fallback.img
 
=== LILO ===
If you use LILO, it is recommended that you use ''append="root=/dev/XYZ"'' instead of ''root=/dev/XYZ''. If you already have a global ''append'' option, then use ''addappend''.
 
boot=/dev/hdX
default = <Label of default image>
timeout=50
vga=791
lba32
prompt
# for the hardware-autodetecting image
image=/boot/vmlinuz26
label=ArchLinux
append="root=/dev/hdXY"
initrd=/boot/kernel26.img
read-only
# fallback image if the other doesnt work (Will most prob. never be used)
image=/boot/vmlinuz26
label=ArchLinuxFallBack
append="root=/dev/hdXY"
initrd=/boot/kernel26-fallback.img
read-only
 
= Troubleshooting =
== piix ide controllers and beyond kernel ==
=== Problem ===
If you are having problems getting mkinitcpio to detect your hard drive giving errors akin to "Can't find device dev(0,0)" when switching to kinit, then this could be because of a conflict that the ata_piix and piix drivers have.  The beyond kernel has some libata patches that cause ata_piix to *conflict* with piix.
 
=== Solution ===
Edit /etc/mkinitcpio.conf to only have ide or sata or scsi depending on what your system actually needs to boot.


{{ÜberFDL||Seite=http://wiki.archlinux.org|Name=ArchLinux.org Wiki|Original=http://wiki.archlinux.org/index.php?title=Configuring_mkinitcpio}}
Ein aktueller Blogeintrag von Dave Reisner zum Thema ''Optimizing Bootup With mkinitcpio'' unter [http://blog.falconindy.com/articles/optmizing-bootup-with-mkinitcpio.html]


[[Kategorie:Konfiguration]]
[[en:Mkinitcpio]]

Version vom 30. Juni 2015, 18:06 Uhr

Einleitung

mkinitcpio ist die nächste Generation der initramfs-Erstellung. Es hat viele Vorteile gegenüber den alten Skripten mkinitrd und mkinitramfs.

  • Es nutzt klibc und kinit der Linux-Entwickler, welches eine kleine und leichtgewichtige Basis bereitstellt, um Programme sehr früh im userspace laufen zu lassen.
  • Es kann mittels udev die Hardware zur Laufzeit erkennen, so dass nur die wirklich nötigen Module geladen werden.
  • Die hook-basierenden init-Scripte sind leicht erweiterbar und können auch durch externe Pakete genutzt werden.
  • Es unterstützt bereits lvm2, dm-crypt (legacy und luks volumes), raid, swsusp und suspend2 Fortsetzen und Starten von usb Datenträgern.
  • Viele Funktionen können von der Kernel-Kommandozeile konfiguriert werden ohne das Image neu erstellen zu müssen.
  • Mit dem mkinitcpio-Skript ist es möglich, das Image in den Kernel zu integrieren.

mkinitcpio wurde von phrakture und tpowa mit einiger Hilfe von der Community entwickelt.

Installation

mkinitcpio ist Bestandteil jeder Arch Linux Installation.

Konfiguration

Die Datei /etc/mkinitcpio.conf editieren, um die Standardeinstellungen zu ändern.

MODULES

Mit dem MODULES-Eintrag können Module explizit dem Image hinzugefügt werden.

Beispiel: Bei Verwendung des nouveau Treiber wird bereits die Konsole beim Starten diesen verwenden.

MODULES="nouveau"

BINARIES und FILES

Mit diesen Optionen können Dateien dem Abbild hinzugefügt werden. Der einzige Unterschied zwischen BINARIES und FILES ist, dass BINARIES die Bibliotheken nach Abhängigkeiten durchsucht, während FILES nur Dateien hinzufügt.

HOOKS

Dies ist der wichtigste Teil der mkinitcpio Konfiguration. Diese Zeile enthält alle HOOKS, welche während der Imageerstellung oder zur Laufzeit ausgeführt werden. Hierbei muss die Reihenfolge beachtet werden:

HOOKS="foo1 foo2 bar1 bar2"

Am besten man prüft anhand des eigenen Systems, welche HOOKS aktuell verfügbar sind. Zusätzlich wird angezeigt, welche als veraltet gelten, und welche zukünftig verwendet werden sollen.

mkinitcpio -L

Für jeden gelisteten HOOK gibt es eine Zusatzinfo.

mkinitcpio -H base

Verfügbare HOOKS

Hook Information
base This hook provides crucial runtime necessities for booting. DO NOT remove this hook unless you know what you're doing.
udev This hook will use udev to create your root device node and detect the needed modules for your root device. It is also required for firmware loading in initramfs. It is recommended to use this hook.
systemd This will install a basic systemd setup in your initramfs, and is meant to replace the 'base', 'usr', 'udev' and 'timestamp' hooks. Other hooks with runtime components will need to be ported, and will not work as intended. You also may wish to still include the 'base' hook (before this hook) to ensure that a rescue shell exists on your initramfs.
modconf This hook installs modprobe configuration files from /etc/modprobe.d and /usr/lib/modprobe.d.
usr This provides a support for mounting /usr via a late running hook. No configuration is needed, as the mount options will be pulled directly from the fstab on the real root device.
autodetect This hook shrinks your initramfs to a smaller size by autodetecting the needed modules. Be sure to verify included modules are correct and none are missing. This hook must be run before other subsystem hooks in order to take advantage of auto-detection. Any hooks placed before 'autodetect' will be installed in full.
sata This hook is deprecated in favor of 'block'
scsi This hook is deprecated in favor of 'block'
usb This hook is deprecated in favor of 'block'
fw This hook is deprecated in favor of 'block'
block This hook loads the necessary modules for most block devices using pata, sata, scsi, firewire, usb, or mmc. Detection will take place at runtime. To minimize the modules in the image, add the autodetect hook too.
usbinput This hook is deprecated in favor of 'keyboard'
keyboard This hook loads the necessary modules for keyboard devices. As a side-effect modules for some non-keyboard input devices might be added to, but this should not be relied on. Detection will take place at runtime. To minimize the modules in the image, add the autodetect hook too.
filesystems This hook adds filesystems modules to the image. If you would like to minimize the modules installed in the image, add the autodetect hook too.
lvm2 This hook enables LVM2 volumes in initramfs. Do pacman -S lvm2 before.
sd-lvm2 This hook enables LVM2 volumes in systemd-based initramfs. Do pacman -S lvm2 before.
mdadm This hook loads the necessary modules for any raid root device, and assembles the raid device when run. If arrays are defined in /etc/mdadm.conf, the file will be used instead of command line assembling. Do pacman -S mdadm before. Please see mkinitcpio -H mdadm
dmraid This hook loads the necessary modules for a dmraid root device. Do pacman -S dmraid before.
encrypt This hook allows for an encrypted root device. Users should specify the device to be unlocked using 'cryptdevice=device:dmname' on the kernel command line, where 'device' is the path to the raw device, and 'dmname' is the name given to the device after unlocking, and will be available as /dev/mapper/dmname. Do pacman -S cryptsetup before. Please see mkinitcpio -H encrypt
sd-encrypt This hook allows for an encrypted root device. Users should specify the device to be unlocked using 'cryptdevice=device:dmname' on the kernel command line, where 'device' is the path to the raw device, and 'dmname' is the name given to the device after unlocking, and will be available as /dev/mapper/dmname. Do pacman -S cryptsetup before. Please see mkinitcpio -H sd-encrypt
resume This hook initializes support for resuming from Disk. Supports swsusp and suspend2.
fschk This hook provides fsck and filesystem specific helpers to perform an fsck operation on the root device prior to mounting. If the autodetect hook is used, only the fsck helper specific to your filesystem will be added to the image. It is highly recommended that if you include this hook that you also include any necessary modules to ensure your keyboard will work in early userspace. Please see mkinitcpio -H fsck
consolefont This hook loads consolefont specified in vconsole.conf during early userspace.
sd-vconsole This hook adds the keymap(s) and font specified in vconsole.conf to the image and loads them during early userspace.

Beispiele:

Diese Konfiguration sollte für die meisten Benutzer funktionieren:

HOOKS="base systemd autodetect modconf block filesystems sd-vconsole fsck"

Du kannst verschlüsselte Dateisysteme innerhalb von lvm nutzen:

HOOKS="base autodetect modconf block lvm2 encrypt filesystems keyboard consolefont fsck"

Du kannst verschlüsselte Dateisysteme innerhalb von lvm nutzen, wenn systemd im Einsatz ist:

HOOKS="base systemd autodetect modconf block sd-lvm2 sd-encrypt filesystems sd-vconsole fsck"

COMPRESSION

# Use this to compress the initramfs image. By default, gzip compression is used. Use 'cat' to create an uncompressed image.
COMPRESSION="xz"

COMPRESSION_OPTIONS

# Additional options for the compressor
COMPRESSION_OPTIONS="-9"

Erstellen des Images

Erstelle das Image mit folgendem Befehl:

# mkinitcpio -p linux

Extrahieren des Images

Wenn du wissen möchtest, was sich innerhalb des initrd-Abbildes befindet, kann du es auspacken und in den enthaltenen Dateien herumstöbern.

Das initrd-Abbild ist ein 'SVR4 CPIO'-Archiv, das durch die Befehle find und bsdcpio erstellt wurde und optional durch ein vom Kernel verstandenes Komprimierungsschema komprimiert wurde: genauer gesagt gzip, bzip2, lzma, lzo oder xz.

mkinitcpio beinhaltet ein Werkzeug namens lsinitcpio, welches die Inhalte des initramfs-Abbildes anzeigt und extrahiert.

Das Anzeigen der Dateien im Abbild geschieht durch:

$ lsinitcpio /boot/initramfs-linux.img

Man kann sich auch eine Auflistung der wichtigen Teile des Abbildes anzeigen lassn:

$ lsinitcpio -a /boot/initramfs-linux.img

Das Extrahieren aller Dateien in das aktuelle Verzeichnis:

$ lsinitcpio -x /boot/initramfs-linux.img

Kernelzeile anpassen

Einige Optionen müssen in der Kernelzeile angegeben werden. Einige Mkinitcpio Hooks haben spezielle Optionen. Um diese soll es in diesem Abschnitt gehen.

Wenn du nicht weißt was die Kernelzeile ist, schau in die Dokumentationen von GRUB oder Syslinux.

Failsafe Modus

Wenn du

break=y

zur Kernelzeile hinzufügst, dann stoppt Init nach dem das Setup vollständig ist und du landest in einer dash shell. Diese kann genutzt werden um sich über den Erfolg des Vorgangs zu versichern. Wenn du dich ausloggst geht der normale Bootvorgang weiter.

Hooks deaktivieren

Du kannst hooks deaktivieren indem du disablehooks zur Kernelzeile hinzufügst:

disablehooks=hook1,hook2,hook2

zum Beispiel

disablehooks=resume

Module blacklisten

Du kannst Module blacklisten indem du disablemodules zur Kernelzeile hinzufügst:

disablemodules=mod1,mod2,mod3

zum Beispiel

disablemodules=ata_piix

Weitere Infos

Ein aktueller Blogeintrag von Dave Reisner zum Thema Optimizing Bootup With mkinitcpio unter [1]