- Parabola GNU/Linux-libre
- Contents
- 1 Overview
- 2 Installation
- 3 Image creation and activation
- 3.1 Generate customized manual initcpio
- 4 Configuration
- 4.1 MODULES
- 4.2 BINARIES and FILES
- 4.3 HOOKS
- 4.3.1 Build hooks
- 4.3.2 Runtime hooks
- 4.3.3 Common hooks
- 4.3.4 Creating a custom hook
- 4.4 COMPRESSION
- 4.5 COMPRESSION_OPTIONS
- 5 Runtime customization
- 5.1 init from base hook
- 5.2 Using RAID
- 5.3 Using net
- 5.4 Using LVM
- 5.5 Using encrypted root
- 5.6 /usr as a separate partition
- 6 Troubleshooting
- 6.1 Extracting the image
- 6.2 Recompressing a modified extracted image
- 7 = «/dev must be mounted» when it already is
- 7.1 Using systemd HOOKS in a LUKS/LVM/resume setup
- 7.2 Possibly missing firmware for module XXXX
- 7.3 Standard rescue procedures
- 7.3.1 Boot succeeds on one machine and fails on another
Parabola GNU/Linux-libre
Summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A detailed guide to the Parabola initramfs creation utility. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This article or section needs expansion. |
Known modules that are not autoloaded during boot process (status stock kernel 2.6.18): scsi_transport_sas , ultrastor , qlogicfas , eata , BusLogic , pas16 , wd7000 , sym53c416 , g_NCR5380_mmio , fdomain , u14-34f , dtc , initio , in2000 , imm , t128 , aha1542 , aha152x , atp870u , g_NCR5380 , NCR53c406a , qlogicfas408 , megaraid_mm , advansys .
If one of the above modules are required for the root device, consider explicitly adding it to /etc/mkinitcpio.conf to avoid kernel panics.
4.2 BINARIES and FILES
These options allow users to add files to the image. Both BINARIES and FILES are added before hooks are run, and may be used to override files used or provided by a hook. BINARIES are auto-located within a standard PATH and dependency-parsed, meaning any required libraries will also be added. FILES are added as-is. For example:
For both, BINARIES and FILES , multiple entries can be added delimited with spaces.
4.3 HOOKS
The HOOKS setting is the most important setting in the file. Hooks are small scripts which describe what will be added to the image. For some hooks, they will also contain a runtime component which provides additional behavior, such as starting a daemon, or assembling a stacked block device. Hooks are referred to by their name, and executed in the order they exist in the HOOKS setting in the config file.
The default HOOKS setting should be sufficient for most simple, single disk setups. For root devices which are stacked or multi-block devices such as LVM, mdadm, or dm-crypt, see the respective wiki pages for further necessary configuration.
Hooks can affect installation – when mkinitcpio is run to generate the image – and/or runtime – via an included script that is run during boot. Scripts can be found within the /lib/initcpio/hooks directory.
The default configuration will work for most users with a standard setup:
If using the image on more than one machine, remove the autodetect hook, which tailors the image to the build machine:
For support for encrypted volumes on LVM2 volume groups:
4.3.1 Build hooks
Build hooks are found in /usr/lib/initcpio/install . These files are sourced by the bash shell during runtime of mkinitcpio and should contain two functions: build and help . The build function describes the modules, files, and binaries which will be added to the image. An API, documented by mkinitcpio(8), serves to facilitate the addition of these items. The help function outputs a description of what the hook accomplishes.
For a list of all available hooks:
Use mkinitcpio’s -H option to output help for a specific hook, for example, to display information about the base hook:
4.3.2 Runtime hooks
Runtime hooks are found in /usr/lib/initcpio/hooks . For any runtime hook, there should always be a build hook of the same name, which calls add_runscript to add the runtime hook to the image. These files are sourced by the busybox ash shell during early userspace. With the exception of cleanup hooks, they will always be run in the order listed in the HOOKS setting.
Runtime hooks may contain several functions:
run_earlyhook : Functions of this name will be run once the API file systems have been mounted and the kernel command line has been parsed. This is generally where additional daemons, such as udev, which are needed for the early boot process are started from.
run_hook : Functions of this name are run shortly after the early hooks. This is the most common hook point, and operations such as assembly of stacked block devices should take place here.
run_latehook : Functions of this name are run after the root device has been mounted. This should be used, sparingly, for further setup of the root device, or for mounting other file systems, such as /usr .
run_cleanuphook : Functions of this name are run as late as possible, and in the reverse order of how they are listed in the HOOKS setting in the config file. These hooks should be used for any last minute cleanup, such as shutting down any daemons started by an early hook.
4.3.3 Common hooks
A table of common hooks and how they affect image creation and runtime follows. Note that this table is not complete, as packages can provide custom hooks.
This article or section needs expansion. |
busybox | systemd | Installation | Runtime |
---|---|---|---|
base | Sets up all initial directories and installs base utilities and libraries. Always keep this hook as the first hook unless you know what you are doing. | — | |
udev | systemd | Adds udevd, udevadm, and a small subset of udev rules to your image. | Starts the udev daemon and processes uevents from the kernel; creating device nodes. As it simplifies the boot process by not requiring the user to explicitly specify necessary modules, using it is recommended. |
usr | Add supports for /usr on a separate partition. | Mounts the /usr partition after the real root has been mounted. | |
resume | — | Tries to resume from the «suspend to disk» state. Works with both swsusp and TuxOnIce. See Hibernation for further configuration. | |
btrfs | ? | Sets the required modules to enable Btrfs for using multiple devices with Btrfs. This hook is not required for using Btrfs on a single device. | Runs btrfs device scan to assemble a multi-device Btrfs root file system when no udev hook is present. The btrfs-progs package is required for this hook. |
autodetect | Shrinks your initramfs to a smaller size by creating a whitelist of modules from a scan of sysfs. 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. | — | |
modconf | Includes modprobe configuration files from /etc/modprobe.d and /usr/lib/modprobe.d | — | |
block | Adds all block device modules, formerly separately provided by the fw, mmc, pata, sata, scsi, usb, and virtio hooks. | — | |
pcmcia | Adds the necessary modules for PCMCIA devices. You need to have pcmciautils installed to use this. | — | |
net | — | Adds the necessary modules for a network device. For PCMCIA net devices, please add the pcmcia hook too. | Provides handling for an NFS-based root file system. |
dmraid | ? | Provides support for fakeRAID root devices. You must have dmraid installed to use this. Note that it is preferred to use mdadm with the mdadm_udev hook with fakeRAID if your controller supports it. | Locates and assembles fakeRAID block devices using dmraid . |
mdadm | ? | Provides support for assembling RAID arrays from /etc/mdadm.conf , or autodetection during boot. You must have mdadm installed to use this. The mdadm_udev hook is preferred over this hook. | Locates and assembles software RAID block devices using mdassemble . |
mdadm_udev | ? | Provides support for assembling RAID arrays via udev. You must have mdadm installed to use this. If you use this hook with a FakeRAID array, it is recommended to include mdmon in the binaries section and add the shutdown hook in order to avoid unnecessary RAID rebuilds on reboot. | Locates and assembles software RAID block devices using udev and mdadm incremental assembly. This is the preferred method of mdadm assembly (rather than using the above mdadm hook). |
keyboard | Adds the necessary modules for keyboard devices. Use this if you have an USB keyboard and need it in early userspace (either for entering encryption passphrases or for use in an interactive shell). As a side effect, modules for some non-keyboard input devices might be added to, but this should not be relied on. | — | |
keymap | sd-vconsole | Adds the specified keymap(s) from /etc/vconsole.conf to the initramfs. | Loads the specified keymap(s) from /etc/vconsole.conf during early userspace. |
consolefont | Adds the specified console font from /etc/vconsole.conf to the initramfs. | Loads the specified console font from /etc/vconsole.conf during early userspace. | |
encrypt | sd-encrypt | Adds the dm_crypt kernel module and the cryptsetup tool to the image. You must have cryptsetup installed to use this. | Detects and unlocks an encrypted root partition. See #Runtime customization for further configuration. |
For sd-encrypt see [1] for available kernel command line options. Alternatively, if the file /etc/crypttab.initramfs exists, it will be added to the initramfs as /etc/crypttab . See [2] manpage for more information on crypttab syntax.
4.3.4 Creating a custom hook
An initcpio hook is just another shell script containing necessary information pointing mkinitcpio which executables should be loaded and with what options. It can be useful in some rare occasions when something is needed in early or late userspace, when not provided by other already installed scripts.
First create the actual script:
Now create the actual hook:
Now edit /etc/mkinitcpio.conf accordingly to include your custom hook. You can also include it in /etc/rc.sysinit to load it in late userspace.
4.4 COMPRESSION
The kernel supports several formats for compression of the initramfs— gzip , bzip2 , lzma, xz (also known as lzma2), lzo , and lz4 . For most use cases, gzip, lzop, and lz4 provide the best balance of compressed image size and decompression speed. The provided mkinitcpio.conf has the various COMPRESSION options commented out. Uncomment one to choose which compression format you desire.
Specifying no COMPRESSION will result in a gzip-compressed initramfs file. To create an uncompressed image, specify COMPRESSION=cat in the config or use -z cat on the command line.
Make sure you have the correct file compression utility installed for the method you wish to use.
4.5 COMPRESSION_OPTIONS
These are additional flags passed to the program specified by COMPRESSION , such as:
In general these should never be needed as mkinitcpio will make sure that any supported compression method has the necessary flags to produce a working image. Furthermore, misusage of this option can lead to an unbootable system if the kernel is unable to unpack the resultant archive.
5 Runtime customization
This article or section needs expansion. |
Runtime configuration options can be passed to init and certain hooks via the kernel command line. Kernel command-line parameters are often supplied by the bootloader. For example, a typical Parabola GRUB entry:
The options discussed below can be appended to the kernel command line to alter default behavior. See Kernel parameters and Parabola Boot Process for more information.
5.1 init from base hook
5.2 Using RAID
First, add the mdadm_udev or mdadm hook to the HOOKS array and any required RAID modules (e.g. raid456, ext4) to the MODULES array in /etc/mkinitcpio.conf .
Kernel Parameters: Using the mdadm hook, you no longer need to configure your RAID array in the kernel parameters. The mdadm hook will either use your /etc/mdadm.conf file or automatically detect the array(s) during the init phase of boot.
Assembly via udev is also possible using the mdadm_udev hook. Upstream prefers this method of assembly. /etc/mdadm.conf will still be read for purposes of naming the assembled devices if it exists.
5.3 Using net
Comprehensive and up-to-date information can be found in the official kernel documentation.
This parameter tells the kernel how to configure IP addresses of devices and also how to set up the IP routing table. It can take up to nine arguments separated by colons: ip= : : : : : :: : .
If this parameter is missing from the kernel command line, all fields are assumed to be empty, and the defaults mentioned in the kernel documentation apply. In general this means that the kernel tries to configure everything using autoconfiguration.
For parameters explanation, see the kernel doc.
If you have multiple network cards, this parameter can include the MAC address of the interface you are booting from. This is often useful as interface numbering may change, or in conjunction with pxelinux IPAPPEND 2 or IPAPPEND 3 option. If not given, eth0 will be used.
If the nfsroot parameter is NOT given on the command line, the default /tftpboot/%s will be used.
If you do not use the nfsroot parameter, you need to set root=/dev/nfs to boot from an NFS root via automatic configuration.
5.4 Using LVM
If your root device is on LVM, you have to add the lvm2 hook. See Add lvm2 hook to mkinitcpio.conf for root on LVM for details.
5.5 Using encrypted root
If using an encrypted root, you have to add the encrypt hook. see Dm-crypt/System configuration#mkinitcpio for detailed information on which hooks to include. Note that mkinitcpio does not support loop-aes yet.
5.6 /usr as a separate partition
If you keep /usr as a separate partition, you must adhere to the following requirements:
- Enable mkinitcpio-generate-shutdown-ramfs.service or add the shutdown hook.
- Add the fsck hook, mark /usr with a passno of 0 in /etc/fstab . While recommended for everyone, it is mandatory if you want your /usr partition to be fsck’ed at boot-up. Without this hook, /usr will never be fsck’d.
- Add the usr hook. This will mount the /usr partition after root is mounted. Prior to 0.9.0, mounting of /usr would be automatic if it was found in the real root’s /etc/fstab . See Fstab
Even without these hooks in place, /usr will be automatically found and mounted by the initramfs, but a setup not using these hooks is not supported.
6 Troubleshooting
6.1 Extracting the image
If you are curious about what is inside the initrd image, you can extract it and poke at the files inside of it.
The initrd image is an SVR4 CPIO archive, generated via the find and bsdcpio commands, optionally compressed with a compression scheme understood by the kernel. For more information on the compression schemes, see #COMPRESSION.
mkinitcpio includes a utility called lsinitcpio which will list and extract the contents of initramfs images.
You can list the files in the image with:
And to extract them all in the current directory:
You can also get a more human-friendly listing of the important parts in the image:
6.2 Recompressing a modified extracted image
After extracting an image as explained above, after modifying it, you can find the command necessary to recompress it. Edit /usr/bin/mkinitcpio and change the line as shown below (line 531 in mkinitcpio v20-1.)
Then running mkinitcpio with its usual options (typically mkinitcpio -p linux-libre ), toward the last 20 lines or so you will see something like:
Which corresponds to the command you need to run, which may be:
7 = «/dev must be mounted» when it already is
The test used by mkinitcpio to determine if /dev is mounted is to see if /dev/fd/ is there. If everything else looks fine, it can be «created» manually by:
(Obviously, /proc must be mounted as well. mkinitcpio requires that anyway, and that is the next thing it will check.)
7.1 Using systemd HOOKS in a LUKS/LVM/resume setup
Using systemd/sd-encrypt/sd-lvm2 HOOKS instead of the traditional encrypt/lvm2/resume requires different initrd parameters to be passed by your bootloader. See this post on forum for details [3].
7.2 Possibly missing firmware for module XXXX
When initramfs are being rebuild after a kernel update, you might get these two warnings:
These can appear to any Parabola users, especially those who have not installed these firmware modules. If you do not use hardware which uses these firmwares you can safely ignore this message.
7.3 Standard rescue procedures
With an improper initial ram-disk a system often is unbootable. So follow a system rescue procedure like below:
7.3.1 Boot succeeds on one machine and fails on another
mkinitcpio’s autodetect hook filters unneeded kernel modules in the primary initramfs scanning /sys and the modules loaded at the time it is run. If you transfer your /boot directory to another machine and the boot sequence fails during early userspace, it may be because the new hardware is not detected due to missing kernel modules.
To fix, first try choosing the fallback image from your bootloader, as it is not filtered by autodetect . Once booted, run mkinitcpio on the new machine to rebuild the primary image with the correct modules. If the fallback image fails, try booting into an Parabola live CD/USB, chroot into the installation, and run mkinitcpio on the new machine. As a last resort, try manually adding modules to the initramfs.
Источник