|
1 |
| -# mkinitcpio-systemd-tool |
| 1 | +##### This file is part of https://github.com/random-archer/mkinitcpio-systemd-tool |
| 2 | + |
| 3 | +## mkinitcpio-systemd-tool |
| 4 | + |
| 5 | +Never write another mkinitcpio hook again, use systemd-tool. |
| 6 | + |
| 7 | +### Summary |
| 8 | + |
2 | 9 | Provisioning tool for systemd in initramfs (systemd-tool)
|
| 10 | + |
| 11 | +Features: |
| 12 | +* initrd debugging |
| 13 | +* early network setup |
| 14 | +* remote ssh access in initrd |
| 15 | +* cryptsetup password answer over ssh |
| 16 | +* unified systemd + mkinitcpio configuration |
| 17 | +* automatic provisioning of binary and config resources |
| 18 | +* on-demand invocation of mkinitcpio scripts and in-line functions |
| 19 | + |
| 20 | +mkinitcpio hook name: `systemd-tool` |
| 21 | + |
| 22 | +### Example |
| 23 | + |
| 24 | +Basic usage steps: |
| 25 | + |
| 26 | +1) activate required hooks in `/etc/mkinitcpio.conf`: |
| 27 | +``` |
| 28 | +HOOKS="base systemd systemd-tool" |
| 29 | +``` |
| 30 | + |
| 31 | +2) review, change and enable/disable provided default files: |
| 32 | +``` |
| 33 | +/etc/systemd/network/initrd-*.network |
| 34 | +/etc/systemd/system/initrd-*.service |
| 35 | +/etc/systemd/system/initrd-*.sh |
| 36 | +``` |
| 37 | + |
| 38 | +3) build/review initrd and reboot |
| 39 | +``` |
| 40 | +mkinitcpio -v -p linux > build.log |
| 41 | +reboot |
| 42 | +``` |
| 43 | + |
| 44 | +### Details |
| 45 | + |
| 46 | +`makepkg/pacman` install actions: |
| 47 | +* provision default files included in this package into the `/etc` |
| 48 | +* specific folders are `/etc/mkinitcpio.d` and `/etc/systemd/{system,network}` |
| 49 | + |
| 50 | +`mkinitcpio` install hook actions: |
| 51 | +* look in the `/etc/systemd/system` |
| 52 | +* include in initrd units containing marker `/etc/initrd-release` |
| 53 | +* activate transitively in initrd any discovered systemd service units |
| 54 | +* auto provision into initramfs resources declared in the initrd service units |
| 55 | + |
| 56 | +### Provisioning Questions and Answers |
| 57 | + |
| 58 | +what is the mkinitcpio hook entry provided by this package? |
| 59 | +* hook name: `systemd-tool` |
| 60 | +* minimum required hooks are: `base systemd systemd-tool` |
| 61 | +* recommended hooks are: `base systemd autodetect modconf block filesystems keyboard systemd-tool` |
| 62 | + |
| 63 | +where can I find stable version of mkinitcpio-systemd-tool? |
| 64 | +* use releases https://github.com/random-archer/mkinitcpio-systemd-tool/releases |
| 65 | + |
| 66 | +how can I enable my custom service unit in initrd? |
| 67 | +* add `[Unit]` entry `ConditionPathExists=/etc/initrd-release` |
| 68 | + |
| 69 | +how can I disable my custom service unit in initrd? |
| 70 | +* alter the tag marker string, i.e.: `ConditionPathExists=/etc/xxx/initrd-release` |
| 71 | + |
| 72 | +what is the purpose of `[X-SystemdTool]` section in service unit files? |
| 73 | +* see https://github.com/systemd/systemd/issues/3340 |
| 74 | +* this section provides configuration interface for `mkinitcpio` provisioning actions |
| 75 | +* entries include: `InitrdBinary=`, `InitrdPath=`, `InitrdLink=`, `InitrdBuild=`, `InitrdCall=` |
| 76 | + |
| 77 | +how can I auto-provision my custom service unit binaries into initramfs? |
| 78 | +* use `InitrdBinary=/path/target-exec` to provision service binary |
| 79 | +* also will be provisioned all `Exec*` entries such as `ExecStart=/bin/program` |
| 80 | + |
| 81 | +how can I auto-provision my custom service unit resources into initramfs? |
| 82 | +* use `InitrdPath=/path/to/host/folder-or-file` |
| 83 | + |
| 84 | +how can I relocate folder during provisioning? |
| 85 | +* not implemented, source and target folder must use the same location |
| 86 | + |
| 87 | +how can I relocate file and/or change file mode during provisioning? |
| 88 | +* use `InitrdPath=/target-file source=/source-file mode=NNN` |
| 89 | + |
| 90 | +how can I filter directory content during provisioning? |
| 91 | +* use `InitrdPath=/target-folder glob=*.example` |
| 92 | + |
| 93 | +how can I provision optional folder or file? |
| 94 | +* use `InitrdPath=/target-file source=/source-file optional=yes` |
| 95 | + |
| 96 | +is there a way to create empty folder or file? |
| 97 | +* for empty dir, use `InitrdPath=/path/target-folder/ create=yes` note trailing SLASH |
| 98 | +* for empty file, use `InitrdPath=/path/target-file create=yes` note NO trailing slash |
| 99 | +* in order to ignore existing host source, add `source=/some-invalid-path` argument |
| 100 | + |
| 101 | +how can I provision a symbolic link? |
| 102 | +* use `InitrdLink=/path-to-link/link-name /path-to-target/target-name` |
| 103 | +* note that `/path-to-target/target-name` must be provisioned separately |
| 104 | + |
| 105 | +can I invoke a provisioning script related to my service during mkinitcpio build time? |
| 106 | +* use `InitrdBuild=/path-to/script.sh command=function_name` |
| 107 | + |
| 108 | +can I call a little provisioning script snippet during mkinitcpio build time? |
| 109 | +* check for available `mkinitcpio` functions in `/usr/lib/initcpio/functions.sh` |
| 110 | +* use `InitrdCall=inline-bash-code-here` to call these functions |
| 111 | + |
| 112 | +how can I provide custom interactive user shell for ssh client |
| 113 | +* change sample shell file located in `/etc/systemd/system/initrd-shell.sh` |
| 114 | + |
| 115 | +which ssh user keys are used by initramfs sshd server? |
| 116 | +* they come from host `/root/.ssh/authorized_keys` |
| 117 | + |
| 118 | +### Shell Script Questions and Answers |
| 119 | + |
| 120 | +there is a `initrd-shell.sh` script provided, what does it do? |
| 121 | +* it used as both interactive login shell and as a systemd service |
| 122 | +* when crypto disks are present, it acts as password agent |
| 123 | +* when in ssh console, it offers simple interactive menu |
| 124 | +* when in systemd service mode, it acts as service |
| 125 | + |
| 126 | +how can I review `initrd-shell.sh` actions during last boot? |
| 127 | +* use `journalctl -b -t shell` |
| 128 | + |
| 129 | +what does `CTRL-C` do to `initrd-shell.sh` in different modes? |
| 130 | +* while in `ssh console`, it will start a menu form `initrd-shell.sh` |
| 131 | +* while in `/dev/tty debug console`, it will exit from `initrd-shell.sh` |
| 132 | +* while in `/dev/console login console`, it will restart the `initrd-shell.sh` service |
| 133 | + |
| 134 | +is there a silent or no-echo mode during password entry in `initrd-shell.sh`? |
| 135 | +* there are two ways to enter silent mode (see `systemd-ask-password.c`): |
| 136 | +* either by pressing `BACKSPACE` as first key or by pressing `TAB` at any time |
| 137 | +* then the prompt will show extra text: `(no echo)` |
0 commit comments