FS#79287 - [systemd] systemd-vconsole hook should fallback to adding default keymap "us"

Attached to Project: Arch Linux
Opened by Tim Ruffing (realorrandom) - Thursday, 03 August 2023, 09:49 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:15 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 7
Private No

Details

Description:

systemd 254 introduced a default vconsole keymap that it sets when no KEYMAP is set in /etc/vconsole.conf, see https://github.com/systemd/systemd/commit/f129d0e77c4c9a0e12ae38cd241cd49846844a80. The default keymap is configurable at build time, the build config defaults to "us".

But the systemd-vconsole hook does not add any keymap to the initrd if no KEYMAP is set in /etc/vconsole.conf. This leads to errors in systemd-vconsole-setup.service in early userspace.

"journalctl --boot --unit systemd-vconsole-setup.service":
[...]
Aug 03 10:13:37 systemd-vconsole-setup[355]: loadkeys: Unable to open file: us: No such file or directory
Aug 03 10:13:37 systemd-vconsole-setup[345]: /usr/bin/loadkeys failed with exit status 1.
[...]
(There are more warnings and errors, see attached log file, but I think they are separate issues, and some of them already existed before this issue appeared.)

On my system, this leads to multiple error messages "[FAIL] Failed to start Virtual Console Setup." (corresponding to multiple ttys) that appear even when "quiet" is set.

Anyway, I believe the proper fix is to build systemd with -D default-keymap="" (see https://github.com/systemd/systemd/pull/28505). Then systemd-vconsole-setup will not try to set anything, i.e., we keep the kernel keymap (which is what we always did, and which is the only fix that gives the user the possibility to stick to the kernel keymap).
(I think "" should be the upstream build default, I'll comment in https://github.com/systemd/systemd/pull/28505).

Additional info:
* mkinitcpio 36-1
* systemd 254-1

Steps to reproduce:
- have a /etc/vconsole.conf without KEYMAP (e.g., the default file /usr/share/factory/etc/vconsole.conf as shipped with systemd)
- run "mkinitcpio -P"
- "lsinitcpio <path> | grep keymaps" is empty

Workaround:
- set KEYMAP=us in /etc/vconsole.conf (which is the build-time-default default keymap https://github.com/systemd/systemd/blob/e3b7fe92e90fd107ea9be30112e00e227ca18501/meson_options.txt#L315, which is used by systemd if no KEYMAP is set explicitly https://github.com/systemd/systemd/blob/f129d0e77c4c9a0e12ae38cd241cd49846844a80/src/vconsole/vconsole-setup.c#L474 )
- run "mkinitcpio -P"
- "lsinitcpio <path> | grep keymaps" has "usr/share/kbd/keymaps/i386/qwerty/us.map" (among others)
This task depends upon

Closed by  Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:15 GMT
Reason for closing:  Moved
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/p ackaging/packages/systemd/issues/9
Comment by Toolybird (Toolybird) - Thursday, 03 August 2023, 10:01 GMT Comment by Tim Ruffing (realorrandom) - Thursday, 03 August 2023, 10:23 GMT
I had not seen this MR. I can't comment there because I don't have an account, but as I wrote above, I think the better fix is to change the systemd build config.
Comment by Tim Ruffing (realorrandom) - Thursday, 03 August 2023, 22:38 GMT
Next systemd will have the special value "kernel" to indicate the kernel keymap https://github.com/systemd/systemd/commit/ef7f5baae8224960f78651e8a3cf4c1f1b870a31
Comment by Toolybird (Toolybird) - Saturday, 05 August 2023, 00:36 GMT
So just to be clear, a default Arch install with untouched mkinitcpio.conf gets a busybox based initrd, and is unaffected.

This issue affects the "sd-vconsole" hook which is typically included when opting for a systemd based initrd. But IIUC, it only affects those systems with an empty or non-existent /etc/vconsole.conf

The mkinitcpio situation should be improved by the aforementioned MR.

We will get the upstream systemd "fixlet" in the next stable bump. But I'm still unclear if our systemd PKGBUILD needs tweaking.
Comment by Toolybird (Toolybird) - Saturday, 05 August 2023, 01:17 GMT
Merging  FS#79296  here.
Comment by Tim Ruffing (realorrandom) - Saturday, 05 August 2023, 09:32 GMT
> But I'm still unclear if our systemd PKGBUILD needs tweaking.

I don't think so. The problem will disappear after the mkinitcpio MR. Now that systemd has decided that they really want the "us" default [2], we shouldn't deviate it from it unless there is a good reason. In particular, "man vconsole.conf" says that KEYMAP= defaults to "us" if not set. So if we reconfigure this at build time, the man page will be wrong.


[1] https://github.com/systemd/systemd/pull/28505#issuecomment-1664056741
Comment by nl6720 (nl6720) - Saturday, 05 August 2023, 09:36 GMT
IMO replacing the keymap if it is not explicitly requested is not sane. I'm hoping for the systemd package to be built with default-keymap=kernel in the future.
Comment by Mike Yuan (YHNdnzj) - Saturday, 05 August 2023, 12:33 GMT
> In particular, "man vconsole.conf" says that KEYMAP= defaults to "us" if not set. So if we reconfigure this at build time, the man page will be wrong.

Not actually. man/vconsole.conf also shows the build-time default: https://github.com/systemd/systemd/blob/804c6397bc39a95968366c031082e96e94ef218c/man/vconsole.conf.xml#L78
Comment by Tim Ruffing (realorrandom) - Saturday, 05 August 2023, 15:05 GMT
Oh, sure. Sorry, I missed this, even though I had looked at the commit earlier.
Comment by Max (qtmax) - Wednesday, 11 October 2023, 10:42 GMT
#79296 is still relevant for systemd 254.5-1. Last good version is 253.7-1.

My set of hooks is: HOOKS=(base systemd autodetect plymouth hostdata modconf block keyboard sd-encrypt filesystems)

My /etc/vconsole.conf contains only comments. I don't need systemd to set fonts in my console, and I want to spare a tiny bit of space in my initramfs, therefore I don't have vconsole.conf configured nor the sd-vconsole hook.

This change https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/commit/4ae88c260a0aeec89956063ccfb887a416f40f52 started installing systemd-vconsole-setup.service as part of the systemd hook, however all the relevant files (such as /usr/lib/systemd/systemd-vconsole-setup, /usr/bin/loadkeys and /usr/bin/setfont) are still added by sd-vconsole. When the systemd hook is used without sd-vconsole, it leads to a failure to load systemd-vconsole-setup.service with the following message in the journal and a brief error message in the terminal:

systemd[1]: systemd-vconsole-setup.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-vconsole-setup.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Virtual Console Setup.
systemd-vconsole-setup[131]: /usr/bin/loadkeys failed with exit status 1.

I believe the fix is as simple as reverting that part of the change that added systemd-vconsole-setup.service to the systemd hook and adding it to sd-vconsole instead. It works for my use case, removing the error message on boot and in the journal, and it shouldn't change anything for those who use sd-vconsole, as systemd-vconsole-setup.service will be installed by that hook.

In other words:

--- /usr/lib/initcpio/install/systemd
+++ /usr/lib/initcpio/install/systemd
@@ -116,7 +116,6 @@
systemd-udevd-kernel.socket \
systemd-udevd.service \
systemd-udev-trigger.service \
- systemd-vconsole-setup.service \
timers.target \
rescue.target \
emergency.target
--- /usr/lib/initcpio/install/sd-vconsole
+++ /usr/lib/initcpio/install/sd-vconsole
@@ -6,6 +6,7 @@
# shellcheck disable=SC2034
local KEYMAP KEYMAP_TOGGLE FONT FONT_MAP FONT_UNIMAP XKBLAYOUT XKBMODEL XKBVARIANT XKBOPTIONS

+ add_systemd_unit systemd-vconsole-setup.service
add_binary /usr/lib/systemd/systemd-vconsole-setup
add_binary loadkeys
add_binary setfont

Unfortunately, I can't register at https://gitlab.archlinux.org/ (as suggested by Toolybird) and submit a pull request. I can't create a regular account, and even after signing with GitHub SSO it asks me to enter a login and password. Can someone assist with creating an account for me, and I'll submit those oneliners?
Comment by Kevin (anonymous_user) - Thursday, 12 October 2023, 02:58 GMT
Send an email to accountsupport@archlinux.org with the username you would like and they will help you.

Loading...