You are not logged in.

#1 2015-04-29 12:05:29

ackalker
Member
Registered: 2012-11-27
Posts: 201

mkinitcpio-systemd-ng: an improved, enhanced systemd hook

I've been working on some improvements and enhancements to the current systemd hook for mkinitcpio.

A quick rundown of my goals:

- Make it possible to fully replace base and udev hooks with this hook (which means being able to depend on a working emergency shell)
- Add missing files (including those needed for working Emergency and Rescue modes, including commands like `shutdown`, `reboot`, etc.)
- Improve code maintainability: fewer hard-coded unit files, more docs
- No password and group files in the initrd image by default, for security reasons
- Add support for drop-in snippets and presets to configure early boot

Optional, supporting hooks and packages may add functionality to:

- Add password and group files to the initrd if desired
- Load keyboard drivers if not compiled into the kernel
- Load a keyboard map (e.g. for password entry using a localized or non-QWERTY keyboard layout)
- Enable kbrequest action (Alt-UpArrow) to activate Rescue mode

For an annotated diff of my changes, please see: https://github.com/ackalker/mkinitcpio- … e8550bab7d

I have uploaded the package mkinitcpio-systemd-ng-git to the AUR for testing.

The systemd-ng hook should be able to replace both base and udev hooks.

Please let me know what you think of this. I hope these changes can somehow make it into Arch Linux official systemd package. Any suggestions and constructive criticism are very welcome.

Here is a diff of the output of `lsinitcpio -v` of an old an new initramfs image (sorted, with date column removed for easy comparison) which makes for a nice summary of the impact of my changes.

--- current systemd hook, replacing udev hook
+++ systemd-ng hook, replacing both base and udev hooks

--- lsinitcpio.out.old	2015-04-30 16:21:31.361298981 +0200
+++ lsinitcpio.out.new	2015-04-30 16:21:31.457964831 +0200
@@ -4 +4 @@
--rw-r--r--   1 root     root         2493 ./buildconfig
+-rw-r--r--   1 root     root         2491 ./buildconfig
@@ -9 +8,0 @@
--rw-r--r--   1 root     root          689 ./etc/group
@@ -11 +10 @@
--rw-r--r--   1 root     root         1747 ./etc/ld.so.cache
+-rw-r--r--   1 root     root         1739 ./etc/ld.so.cache
@@ -15,2 +13,0 @@
--rw-r--r--   1 root     root          234 ./etc/nsswitch.conf
--rw-r--r--   1 root     root          832 ./etc/passwd
@@ -18 +14,0 @@
--rw-r--r--   1 root     root        12469 ./init_functions
@@ -63 +59 @@
-lrwxrwxrwx   1 root     root            7 ./usr/bin/halt -> busybox
+lrwxrwxrwx   1 root     root            9 ./usr/bin/halt -> systemctl
@@ -75,0 +72 @@
+-rwxr-xr-x   1 root     root       449896 ./usr/bin/journalctl
@@ -93 +90 @@
--rwxr-xr-x   1 root     root       146576 ./usr/bin/modprobe
+lrwxrwxrwx   1 root     root            4 ./usr/bin/modprobe -> kmod
@@ -105 +102 @@
-lrwxrwxrwx   1 root     root            7 ./usr/bin/poweroff -> busybox
+lrwxrwxrwx   1 root     root            9 ./usr/bin/poweroff -> systemctl
@@ -110 +107 @@
-lrwxrwxrwx   1 root     root            7 ./usr/bin/reboot -> busybox
+lrwxrwxrwx   1 root     root            9 ./usr/bin/reboot -> systemctl
@@ -121,0 +119 @@
+lrwxrwxrwx   1 root     root            9 ./usr/bin/shutdown -> systemctl
@@ -126 +124 @@
--rwxr-xr-x   1 root     root        14832 ./usr/bin/switch_root
+-rwxr-xr-x   1 root     root        39976 ./usr/bin/sulogin
@@ -153,0 +152 @@
+-rwxr-xr-x   1 root     root        39184 ./usr/lib/libcrypt.so.1
@@ -163,2 +161,0 @@
--rwxr-xr-x   1 root     root        51712 ./usr/lib/libnss_files-2.21.so
-lrwxrwxrwx   1 root     root           20 ./usr/lib/libnss_files.so.2 -> libnss_files-2.21.so
@@ -207,2 +204,2 @@
-drwxr-xr-x   4 root     root            0 ./usr/lib/systemd
-drwxr-xr-x   4 root     root            0 ./usr/lib/systemd/system
+drwxr-xr-x   5 root     root            0 ./usr/lib/systemd
+drwxr-xr-x   7 root     root            0 ./usr/lib/systemd/system
@@ -212,0 +210,4 @@
+drwxr-xr-x   2 root     root            0 ./usr/lib/systemd/system-preset
+-rw-r--r--   1 root     root           42 ./usr/lib/systemd/system-preset/80-initrd.preset
+-rw-r--r--   1 root     root           10 ./usr/lib/systemd/system-preset/99-default.preset
+-rw-r--r--   1 root     root          403 ./usr/lib/systemd/system/-.slice
@@ -214 +214,0 @@
-lrwxrwxrwx   1 root     root           13 ./usr/lib/systemd/system/ctrl-alt-del.target -> reboot.target
@@ -216,0 +217,3 @@
+drwxr-xr-x   2 root     root            0 ./usr/lib/systemd/system/emergency.service.d
+-rw-r--r--   1 root     root          350 ./usr/lib/systemd/system/emergency.service.d/25-keyboard.conf
+-rw-r--r--   1 root     root          185 ./usr/lib/systemd/system/emergency.service.d/50-sulogin-force.conf
@@ -218,0 +222 @@
+-rw-r--r--   1 root     root          487 ./usr/lib/systemd/system/halt.target
@@ -226,0 +231 @@
+-rw-r--r--   1 root     root          501 ./usr/lib/systemd/system/kexec.target
@@ -230,0 +236 @@
+-rw-r--r--   1 root     root          552 ./usr/lib/systemd/system/poweroff.target
@@ -231,0 +238,4 @@
+-rw-r--r--   1 root     root          978 ./usr/lib/systemd/system/rescue.service
+drwxr-xr-x   2 root     root            0 ./usr/lib/systemd/system/rescue.service.d
+-rw-r--r--   1 root     root          185 ./usr/lib/systemd/system/rescue.service.d/50-sulogin-force.conf
+-rw-r--r--   1 root     root          486 ./usr/lib/systemd/system/rescue.target
@@ -245,0 +256 @@
+lrwxrwxrwx   1 root     root           52 ./usr/lib/systemd/system/sysinit.target.wants/systemd-modules-load.service -> /usr/lib/systemd/system/systemd-modules-load.service
@@ -248,0 +260 @@
+-rw-r--r--   1 root     root          433 ./usr/lib/systemd/system/system.slice
@@ -249,0 +262 @@
+-rw-r--r--   1 root     root          548 ./usr/lib/systemd/system/systemd-halt.service
@@ -254,0 +268,3 @@
+-rw-r--r--   1 root     root          561 ./usr/lib/systemd/system/systemd-kexec.service
+-rw-r--r--   1 root     root          956 ./usr/lib/systemd/system/systemd-modules-load.service
+-rw-r--r--   1 root     root          557 ./usr/lib/systemd/system/systemd-poweroff.service
@@ -260,0 +277,2 @@
+drwxr-xr-x   2 root     root            0 ./usr/lib/systemd/system/systemd-udevd.service.d
+-rw-r--r--   1 root     root          149 ./usr/lib/systemd/system/systemd-udevd.service.d/50-systemd-udevd-resolve-never.conf
@@ -265,0 +284,2 @@
+-rwxr-xr-x   1 root     root        51912 ./usr/lib/systemd/systemd-modules-load
+-rwxr-xr-x   1 root     root       105176 ./usr/lib/systemd/systemd-shutdown
@@ -283 +303 @@
-Image size: 5288037 bytes
+Image size: 5518816 bytes

Last edited by ackalker (2015-05-01 13:36:08)

Offline

#2 2015-04-29 12:33:46

ackalker
Member
Registered: 2012-11-27
Posts: 201

Re: mkinitcpio-systemd-ng: an improved, enhanced systemd hook

Known issues (will be updated when needed, be sure to check):

* Depending on how the iernel is configured, keyboard input in Emergency mode might not work without the fix below.
To test, boot the system with added kernel boot parameter `rd.systemd.unit=emergency.target`.
If keyboard input doesn't work, install the optional package systemd-emergency-keyboard-git from the AUR.

* Booting to Emergency mode in QEMU with serial console and QEMU monitor multiplexed over stdio (kernel command line parameters: `console=ttyS0 rd.systemd.unit=emergency.target`, QEMU options `-nographic  -serial mon:stdio`), I have to type at least one other character before hitting Enter, or else keyboard input stops working. This problem does not occur for me when booting real hardware (tested with USB keyboard).
From some more testing, it appears to be a problem with the use of `sulogin --force`, replacing that with `sh -l` there are no keyboard issues.

Planned features (help implementing them very welcome):

* Support for adding and masking services in the initrd. This requires changes in the way the hook handles unit dependencies and symlinks.

Last edited by ackalker (2015-04-30 14:47:12)

Offline

#3 2015-04-30 14:03:35

ackalker
Member
Registered: 2012-11-27
Posts: 201

Re: mkinitcpio-systemd-ng: an improved, enhanced systemd hook

v0.2 update:
- Collect all drop-in snippets in a single directory
- Move keyboard drop-in snippet to a new optional package in the AUR: systemd-emergency-keyboard-git.

Updated known issues.

Last edited by ackalker (2015-04-30 14:04:57)

Offline

#4 2015-09-20 15:12:03

ackalker
Member
Registered: 2012-11-27
Posts: 201

Re: mkinitcpio-systemd-ng: an improved, enhanced systemd hook

v0.3 update:
- Fix processing of udev rules (taken from official systemd hook)

v0.4 update:
- Revert workaround for kernel module load (fixed upstream in kmod)

Last edited by ackalker (2015-09-20 15:12:41)

Offline

#5 2015-09-20 21:55:15

damjan
Member
Registered: 2006-05-30
Posts: 454

Re: mkinitcpio-systemd-ng: an improved, enhanced systemd hook

what's the general differnece between this initramfs and the arch default one?

Offline

Board footer

Powered by FluxBB