Subject: WIP: trying to add consolefont in mkinitfs

From: David Demelier <[email-masked]>
Date: Tue, 28 Jan 2020 10:23:48 +0100

Hello all,

I'm trying to create an additional features for mkinitfs, including 
setfont + console fonts.

Why? Because on some laptops with high dpi screens, the initramfs may 
ask passphrase for cryptsetup or show an emergency shell. On my laptop 
this is barely usable by default.

Thus, I've created a /etc/mkinitfs/features.d/consolefont with

/etc/conf.d/consolefont
/usr/sbin/setfont
/usr/share/consolefonts/*.psf.gz

Then, updated initramfs-init just before the first message [0]

--- initramfs-init.orig
+++ initramfs-init
@@ -353,6 +353,7 @@
         done
  done

+# Just for testing yet.
+setfont /usr/share/consolefonts/ter-224n.psf.gz
  [ "$KOPT_quiet" = yes ] || echo "Alpine Init $VERSION"

  # enable debugging if requested

I've enabled consolefont in my mkinitfs.conf and rebooted.

At boot setfont complained that /dev/tty does not exist even though 
printing on the screen does not work and cryptsetup asks the passphrase 
so... I'm unable to understand how can I achieve this. Is it possible to 
create a /dev/tty node? Should mdev be enabled earlier?

[0]: https://git.alpinelinux.org/mkinitfs/tree/initramfs-init.in#n355

Any help is welcomed.

-- 
David

---

From: Nero <[email-masked]>
Date: Tue, 28 Jan 2020 10:05:21 +0000

Hi,

On Tue, Jan 28, 2020 at 10:23:48AM +0100, David Demelier wrote:
> Hello all,
> 
> I'm trying to create an additional features for mkinitfs, including setfont
> + console fonts.
> 
> Why? Because on some laptops with high dpi screens, the initramfs may ask
> passphrase for cryptsetup or show an emergency shell. On my laptop this is
> barely usable by default.
> 
> At boot setfont complained that /dev/tty does not exist even though printing
> on the screen does not work and cryptsetup asks the passphrase so... I'm
> unable to understand how can I achieve this. Is it possible to create a
> /dev/tty node? Should mdev be enabled earlier?
> 

The stdio of the /init script in the initramfs is connected to /dev/console,
which does not have all of the functionality a usual tty is expected to have.

Internally, /dev/console is wired to output on all tty devices that are
specified via the console= kernel boot parameter.

Despite this, the /dev/tty should be available from the devtmpfs. Maybe it
might help to insert /bin/sh into the initramfs script to start an
interactive shell and poke around manually with `setfont`. Having `strace`
in the initramfs might be handy there.

Also, maybe its worth trying with /dev/tty0 (current virtual console). Setting
the font is an operation that only applies to the linux virtual consoles.
/dev/tty (current console) might end up pointing to some serial line.

--
Nero

---

From: David Demelier <[email-masked]>
Date: Wed, 29 Jan 2020 20:57:52 +0100

> in the initramfs might be handy there.

Thank you for your answer.

I've listed the devices inside the init script, there is a lot of
/dev/tty* devices including /dev/tty.

Note the error is “No such device or address”.

So I'm out of ideas yet. Maybe I should do a for loop or try to another
tty.

-- 
Davi