Changing the console font in the initfs
I'm trying to change the console font size on the initfs.
I mostly interact with the console before the main partition is unlocked (providing a passphrase), so changing the font via an openrc service is a bit too late.
When cryptsetup tells me that I've provided the wrong password, I sometimes miss this due to the tiny fonts (it low-key bothers me that font size change halfway through boot, although that's not terrible).
I applied this small patch to initramfs-init
:
--- initramfs-init.in
+++ /usr/share/mkinitfs/initramfs-init
@@ -574,6 +574,12 @@
$MOCK modprobe -a ata_piix mptspi sr-mod
fi
+if [ -f /usr/share/consolefonts/default.gz ] && [ -x /usr/sbin/setfont ]; then
+ /usr/sbin/setfont -C /dev/tty0 /usr/share/consolefonts/default.gz
+ echo font changed
+ sleep 2
+fi
+
if [ -n "$KOPT_cryptroot" ]; then
cryptopts="-c ${KOPT_cryptroot}"
if [ "$KOPT_cryptdiscards" = "yes" ]; then
And added the following to /etc/mkinitfs/features.d/consolefont.files
:
/usr/share/consolefonts/default.gz
I finally symlinked default.gz
to a font of my choice (ter-132n.psf.gz), added consolefont
to mkinitfs.conf
, and rebuilt my initfs (the default initfs already contains the busybox implementation of setfont
).
This successfully changed the console font (to one nice and large and easy to read!)!
However, as soon as nlplug-findfs
runs, the font resets back to the default tiny size. I suspect that this is a side effect of mdev, but haven't been able to pinpoint down the exact cause. I would appreciate any potential guidance at this point.