FS#65148 - [mkinitcpio] consolefont hook does not change font if a quiet boot

Attached to Project: Arch Linux
Opened by solsTiCe (zebul666) - Wednesday, 15 January 2020, 10:30 GMT
Last edited by freswa (frederik) - Saturday, 12 August 2023, 13:11 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Giancarlo Razzolini (grazzolini)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

If you are using consolefont hook in mkinitcpio HOOKS and encrypt hook for example, one can clearly see that the font is not set when you have to enter your LUKS passphrase.

It happens when you are using a quiet boot using (quiet loglevel=3 vga=current for example)

It seems the console is not initialiazed or something of the kind and setfont has no effect.
During my tries, I found that an error outputted on screen, wakes up the console and let setfont do its job.

I am using systemd-boot and mkinitcpio-busybox (the default udev one)

A fix would be, when quiet is detected in /proc/cmdline to force something to be displayed on the screen so that setfont finally works.
This task depends upon

Closed by  freswa (frederik)
Saturday, 12 August 2023, 13:11 GMT
Reason for closing:  Fixed
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/m kinitcpio/mkinitcpio/-/merge_requests/25 5
Comment by freswa (frederik) - Monday, 20 January 2020, 00:50 GMT
Could you please post your HOOKS Array from mkinitcpio.conf?
Comment by solsTiCe (zebul666) - Monday, 20 January 2020, 08:56 GMT
Here it is:

HOOKS="base udev autodetect keyboard keymap modconf block consolefont encrypt lvm2 resume filesystems fsck"
Comment by freswa (frederik) - Monday, 20 January 2020, 14:06 GMT
Do you do early KMS start? Please have a look at the last paragraph here [0] and make sure the graphicsdriver is loaded early.

[0] https://wiki.archlinux.org/index.php/Linux_console#Persistent_configuration
Comment by solsTiCe (zebul666) - Monday, 20 January 2020, 15:16 GMT
Here is more of my configuration:

$ grep -v ^# /etc/mkinitcpio.conf
MODULES="i915"
BINARIES=""
FILES=""
HOOKS="base udev autodetect keyboard keymap modconf block consolefont encrypt lvm2 resume filesystems fsck"

$ cat /etc/vconsole.conf:
KEYMAP=fr-latin1
FONT=ter-118b

$ pacman -Qs terminus
local/terminus-font 4.48-1
Monospace bitmap font (for X11 and console)

$ cat /boot/loader/loader.conf
default arch
auto-firmware

$ cat /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options quiet loglevel=3 vga=current root=/dev/vg/root cryptdevice=UUID=xxxxxxxx-yyyy-yyyy-yyyy-zzzzzzzzzzzz:arch cryptkey=/dev/disk/by-id/someusbdevice@123456@2048 udev.log_priority=3 vt.global_cursor_default=0 i915.fastboot=1 resume=/dev/vg/swap

(to get an explanation for the @ in cryptkey, see my comment in https://bugs.archlinux.org/task/60927#comments)

I can upload somewhere my initramfs.img if you really want to
Comment by freswa (frederik) - Monday, 20 January 2020, 16:00 GMT
Do you have any console output before the password prompt?

The dracut folks seem to have tackled this a while ago... https://bugzilla.redhat.com/show_bug.cgi?id=811007
Comment by solsTiCe (zebul666) - Monday, 20 January 2020, 16:17 GMT
No. not even a systemd version. That's why I have the problem, I think.

Like I said, if I output something on screen before setfont in consolefont hook, then the font is changed

I have double checked that the font is in the initramfs.img and is actually ter-118b
Comment by freswa (frederik) - Monday, 20 January 2020, 16:22 GMT
Let's try to boot with rd.debug and rd.log=file to see if the command gets executed before the encrypt hook.
Please upload /run/initramfs/init.log here.
Comment by solsTiCe (zebul666) - Monday, 20 January 2020, 19:27 GMT
I am sorry to say that my netbook did not boot with these settings. I don't know why. may be its limited capacity (2GB RAM ?)
It gets stuck at a blank screen

So instead, I modifed the consolefont hook to get a log of the acces time of the font used as in the patch I attached.

and rerun mkinitcpio and rebooted.

the log file I get from that is:
$ cat /run/initramfs/consolefont.log
-rw-r--r-- 1 0 0 9983 Jan 1 1970 /consolefont.psf
-rw-r--r-- 1 0 0 9983 Jan 20 19:19 /consolefont.psf

So it is very likely that setfont is actually run (at least, it tries to access the font file)
Comment by Bob Collins (BobCollins) - Friday, 08 May 2020, 05:04 GMT
My take:
The config file /etc/vconsole.conf where the font is specified is on the still encrypted root partition when the consolefont HOOK is encountered.
The encrypt HOOK, the passphrase entry, and access to /etc/vconsole.conf all happen later.

So, how can the consolefont HOOK ever work on an encrypted root partition?
Comment by solsTiCe (zebul666) - Friday, 08 May 2020, 10:00 GMT
This is wrong.

`vconsole.conf` is copied by mkinitcpio into `initramfs-linux.img`. And this is the copy from there that is used during the early boot
Comment by Giancarlo Razzolini (grazzolini) - Friday, 08 May 2020, 14:36 GMT
I *strongly* advise for the usage of early KMS. And the removal of vga=current from the grub configuration.
Comment by Bob Collins (BobCollins) - Friday, 08 May 2020, 15:35 GMT
Thanks solsTiCe (zebul666)! This makes sense. I had failed to run mkinitcpio after creating /etc/vconsole.conf

I have now run mkinitcpio -P, and the font has properly changed for the "Enter passphrase" prompt.

I know it's the wrong place to ask this, but I now have a new problem: I can't enter the passphrase at the prompt.

In addition to changing the font via /etc/vconsole.conf, I also changed the keymap to remap CapsLock to Ctrl.

I have not found a wiki entry to help me with this.

Setup:

HOOKS=(base udev autodetect keyboard keymap consolefont modconf block encrypt lvm2 filesystems fsck)

/usr/local/share/kbd/keymaps/local_remap.map
keymaps 0-255
keycode 58 = Control

/etc/vconsole.conf
FONT=sun12x22
KEYMAP=/usr/local/share/kbd/keymaps/local_remap.map

Edit: Also, I am using systemd-boot, not GRUB
Comment by Eli Schwartz (eschwartz) - Friday, 08 May 2020, 15:53 GMT
You're correct, this is the wrong place. Please take this discussion elsewhere. (If you think it is a bug, open a new bug for it.)
Comment by Giancarlo Razzolini (grazzolini) - Friday, 08 May 2020, 15:55 GMT
You have to copy that map you've done to the initramfs. Use the FILES array on mkinitcpio.conf
Comment by Gabor (otnegy) - Friday, 05 June 2020, 01:51 GMT
Hello,

I have this issue, and don't see here what the solution is.

I have i915.fastboot=1 kernel parameter, nothing else related to vga. And if I have the quiet param the password prompt font doesn't change.

I don't understand what the "early KMS" is.

Can you help me?
Thanks

Comment by freswa (frederik) - Friday, 05 June 2020, 01:53 GMT
This is not a support ticket. Please use the forum, the IRC or the mailing list to ask questions.
Thank you
Comment by freswa (frederik) - Friday, 05 June 2020, 15:48 GMT
From Gabor:

I was able to add rd.debug rd.log=file as you suggested (just had to figure out I don't see the password prompt and have to type my disk password on a blank screen)
Inspected the log and the consolefont hook is ok.

I have spent a couple of hours with it and ended up with a workaround adding echo -en "a\010 \010" to /usr/lib/initcpio/hooks/consolefont before setfont -C /dev/console /consolefont.psf

Why?

It looks like setfont doesn't work if nothing was echo-ed before the console.
echo -n " " not works
echo -n "a" works
echo -n "a" ;clear works
Maybe I am wrong, but I thought maybe echo-ing just one char and deleting it back is faster than clear, so this is the echo -en "a\010 \010" ("a",back,overwrite with space,back)
Comment by Buggy McBugFace (bugbot) - Tuesday, 08 August 2023, 19:11 GMT
This is an automated comment as this bug is open for more then 2 years. Please reply if you still experience this bug otherwise this issue will be closed after 1 month.
Comment by Gerry Kessler (renegat) - Thursday, 10 August 2023, 18:44 GMT
This but is still present and more serious than ever since update systemd 254.1 as the sd-vconsole hook no longer works at all. With sd-vconsole hook neither keymap nor consolefont is applied anymore.

With consolefont hook:

It does not matter if BINARIES="setfont" is set or not - the consolefont will not be applied at erly boot (LUKS password prompt e.g.)

Without BINARIES="setfont" in mkinitcpio.conf you'll get error message:
"setfont: KDFONTOP: Function not implemented"
with BINARIES="setfont" you will get error:
"setfont: ERROR kdfontop.c:183 put_font_kdfontop : Unable to load sich font with such kernel version"
Comment by solsTiCe (zebul666) - Thursday, 10 August 2023, 22:09 GMT
Yes, the bug still exists.

But as explained earlier, it is a mattter of adding a line in /usr/lib/initcpio/hooks/consolefont

As the maintainer does not care to fix it (why?), I have made a pacman hook to fix it at each upgrade:

[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = mkinitcpio

[Action]
Description = Patching consolefont hook [#FS65148]
When = PostTransaction
Depends = sed
Exec = /usr/bin/sed -i '/ *setfont/i\ echo -en "a\\010 \\010"' /usr/lib/initcpio/hooks/consolefont

@reneagat works fine with this fix. no error for me here. you can ignore the message "setfont: KDFONTOP: Function not implemented" it is harmless
Comment by nl6720 (nl6720) - Friday, 11 August 2023, 07:48 GMT
If you have a working fix, create a merge request with it in https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio.
Comment by solsTiCe (zebul666) - Saturday, 12 August 2023, 13:04 GMT

Loading...