#620041 Please configure the font and the keymap during initrd phase

#620041#5
Date:
2009-06-12 08:06:17 UTC
From:
To:
Hi,

/etc/rcS.d/S49console-setup is run rather late in the rcS runlevel,
leading to a visible and ugly flickering of the screen and changing of
the font during the system boot process.

I don't know if this is possible technically, but if the font and
keymap setting was moved to the initrd-phase, the whole boot process
would appear in the improved font and it would not be interrupted by
visible flickering and font changing anymore.

Best Regards,
Fabian

#620041#10
Date:
2009-06-12 09:45:44 UTC
From:
To:
Am 12.06.2009 um 10:06 schrieb Fabian Greffrath:

FWIW, Ubuntu has been doing this for more than two years, according to
their changelog:

,----
| console-setup (1.13ubuntu6) feisty; urgency=low
|
|   * Set keymap and font in the initramfs if possible. Setting these as early
|     as possible is a good thing; we can't set up the font correctly once
|     usplash is running; and setting up the font between usplash and X
|     requires an ugly mode switch.
|
|  -- Colin Watson <cjwatson@ubuntu.com>  Mon, 22 Jan 2007 14:21:24 +0000
`----

The downside is that their package depends on initramfs-tools which
would probably not be desirable for Debian.

Sven

#620041#15
Date:
2009-06-12 10:45:37 UTC
From:
To:
Sven Joachim schrieb:

The ubuntu changelog tells "Set keymap and font in the initramfs if
possible.". The phrase "if possible" sounds like this feature will
simply be unavailable if the appropriate initrd tool package isn't
found, so console-setup wouldn't have to depend on this package (but
maybe suggest it instead).

#620041#24
Date:
2010-03-12 20:20:43 UTC
From:
To:
it seems like #532852 (Please run console-setup during initrd phase)
would also affect systems with a crypted root.

that is, entering the passphrase to unlock the block device backing the
root filesystem could be done with the machine's "preferred" keymap,
instead of with whatever default appears.

#620041#37
Date:
2011-03-29 12:47:13 UTC
From:
To:
In the new version of console-setup (1.72) setupcon has a new option
--setup-dir (for now it is undocumented).  If you want to configure the 
console (both the font, the encoding and the keyboard) during the initrd
phase, this can be achieved easily in the following way.  Suppose
/tmp/initrd/ has the files of the future initrd image.  Then run the
following command:

   setupcon --setup-dir /tmp/initrd

This will create an extremely simple script /tmp/initrd/bin/setupcon
that you can use in order to configure the console.  Additionaly, in
/tmp/initrd/etc/console-setup/ the files required for the configuration
will be copied.

Notice that among these files, there will be device files for tty1-tty6.
The configuration script of Ubuntu for the console uses mknod to create
such device files.  The current method of console-setup is simpler to
implement (because the code is shared between Linux and kFreeBSD), it
will not be, however, difficult to change initrd/bin/setupcon to use
mknod and to remove the device files from the initrd image.  Please
tell, if you want this change.

Lastly, setupcon will create a file /tmp/initrd/morefiles.  This file
doesn't have to be included in the initrd image.  Instead it lists the
utilities that must be included in the initrd image.  Depending on
whether kbd or console-tools is installed this will be

/bin/kbd_mode
/bin/setfont
/usr/bin/loadkeys (notice that this is a symlink to /bin/loadkeys)

or

/usr/bin/kbd_mode
/usr/bin/consolechars
/bin/loadkeys

One advantage of the early console configuration is that there will be
no need to change the font during the execution of the boot scripts, the
screen will not flicker and the full history will be preserved on the
console. In order achieve this the boot scripts of console-setup have to
know that the console has been already configured by initrd.  Please,
advice how this can be achieved.  I suppose the following is one
possible method:

1. initrd creates an empty file /tmp/console-is-configured

2. the boot scripts of console-setup do not configure the console if
they see such a file.

3. They, however, remove this file (so these scripts can be used
normally after the system boots and /tmp is not poluted with unnecessary
file).

Anton Zinoviev

#620041#44
Date:
2017-04-07 01:21:39 UTC
From:
To:
Being able to set the font during initramfs would be immensely useful on my
HiDPI laptop, since the default console font renders the LUKS decryption
prompt at a minuscule size I can barely read.

#620041#49
Date:
2022-04-18 04:26:54 UTC
From:
To:
The main problem is that, should system booting fail and get dropped into the Busybox rescue shell, rescuing will be hampered by the kernel having remained on US keymap assumptions. This makes it very difficult to perform emergency maintenance on systems with a non-US keyboard.

Two possible solutions:

1) Use KEYMAP=y as the stock upstream default. There however may be reasons why this would be undesirable.

2) Migrate to a new KEYMAP=auto stock default (similar to BUSYBOX=auto) and install the keymap into the initrd image if the utilities are present on the system. This would probably be the best solution in the long run.

Martin-Éric

- -- System Information:
Debian Release: bookworm/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'stable-security'), (500, 'testing')
Architecture: i386 (i586)

Kernel: Linux 5.16.0-6-686 (SMP w/1 CPU thread; PREEMPT)
Kernel taint flags: TAINT_CPU_OUT_OF_SPEC
Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8), LANGUAGE=fi:en
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages initramfs-tools-core depends on:
ii  coreutils    8.32-4.1
ii  cpio         2.13+dfsg-7
ii  e2fsprogs    1.46.5-2
ii  klibc-utils  2.0.10-4
ii  kmod         29-1
ii  logsave      1.46.5-2
ii  udev         250.4-1

Versions of packages initramfs-tools-core recommends:
ii  busybox-static [busybox]  1:1.30.1-7+b2
ii  zstd                      1.5.2+dfsg-1

Versions of packages initramfs-tools-core suggests:
ii  bash-completion  1:2.11-6

- -- Configuration Files:
/etc/initramfs-tools/initramfs.conf changed:
MODULES=most
BUSYBOX=auto
KEYMAP=y
COMPRESS=zstd
DEVICE=
NFSROOT=auto
RUNSIZE=10%
FSTYPE=auto


- -- no debconf information
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEyJACx3qL7GpObXOQrh+Cd8S017YFAmJc6IQACgkQrh+Cd8S0
17YLvA//e88s7yi67XVaeJpy6SotDGBDUfcZNi1S1XdbbrYdHcyitN1rx6HZURzi
Vii7IthpOkA2le2FsbJ6HXtXW98JQ/iGi8Vz1cWqNLlkpLRRlNIoFa9eb2uHZljg
BmMRYB3AS7UApZNaTlBbmiTyobJEqlRXj6YZ4kuPMSuH2C9q1BMs+Y2CTxKMcy+y
OzSdGhjpAjEdR176uvOowBL+FUK62DeSYpCiyqBN6JN4dhhtempE4FZK2PlM0JG0
L5DrT6vK7wzj+lOKuENK6E0ZKezb2X399Tv64OjSJ+Bz11Au9gTi3jhSt51DXaen
oCMhnu1ogt4LvNt+yG4iNSgBqWr5pcjtg8YUCADC7Bt8zmuEy9Au8/QvS0ypogwH
VXXrZxf6whFn8iUEHOMqNxj80iEm0QYgf/uEdL4VKX8e5Npx5nEIgYKrjYzPByET
9WlRLLnzxw37IQCMkca9sxPotqErP1g8C5YB2Nwy3q7Jwm0Qi4uMfT45TdTW6j93
SLHcmuEIjM26iqWr2YlHFvNCszgwxzkHlZbIspzRWmB+Roem0cL+8pO3/jLR5Hks
FRkII85ywM/EhnqjZV1qqpXkxwMX5j9h84+v4gtWZtpMWCH+StyX6WzGWWIRL9pc
ccnV9LqZeU6OtOSma0XpjDxrAbbtfoMnSEd7k3VAE6LXkgdNmzQ=
=R5Vp
-----END PGP SIGNATURE-----