This is specifically written for Arch Linux users, even so many of those methods can be applied to other distributions as well, because they are using the same packages. Little changes might be needed depending on the configuration of those packages.
force preboot environment #
In order to get into the base hook of mkinitcpio
even so nothing is
broken
break=premount
can be specified as kernel parameter. It is called
APPEND ... break=premount
when using syslinux as boot manager.
manually booting from the preboot environment #
In order to boot manually
mount /dev/md1 /new_root/
exec /usr/bin/switch_root /new_root /sbin/init
source{.fright}
exec
will effectivly replace the current process (which is 1) with the
new process, which is switch_root
in the first place, but which also
uses exec to execute its second parameter, so that finally /sbin/init
gets executed as process 1. With /sbin/init
being part of systemd
it
would have leat to the error “trying to run as user instance but the
system has not been booted with systemd” in case it gets executed with a
PID other than 1.
mkinitcpio's systemd hook #
In order to use encrypted file systems together with the new systemd
hook one needs another hook, which depends on it and which is called
sd-encrypt
. It might get in your way, that because systemd now manages
the order in which devices get initialized, that device mapping from
/etc/crypttab
do not fit any longer. It is therefore advised to use
/dev/disk/by-label/usb-key
like paths even in /etc/crypttab
custom hooks in early userspace #
While system hooks are located under /usr/lib/initcpio/hooks
with
install scripts located in /usr/lib/initcpio/install
. The same
directory structure can be found under /etc/initcpio
and to add a
custom hook a file is required at least in the 'install' directory. A
minimal file looks like this:
#!/bin/bash
build() {
:
}
# vim: set ft=sh ts=4 sw=4 et:
whereas in the hooks directory it has another shebang due to the fact, that it gets executed in early user space:
#!/usr/bin/ash
run_hook() {
echo "Welcome Max!"
}
# vim: set ft=sh ts=4 sw=4 et: