Keyboard layout ignored in initramfs since kernel 4.4.0-34. How to use non-US layout?

Solution 1:

I had the same problem on a fresh install* of ubuntu 17.10.

This bit of information by F.Raab was proven very useful:

However /usr/share/initramfs-tools/hooks/console_setup do not generate /etc/console-setup/cached.kmap.gz and just use the existing one, in contrast to Debian. I assume that the generation has to do once right and then it should work again and then call ´update-initramfs -u`.

It seems the file /etc/console-setup/cached.kmap.gz was missing on my system, and apparently, the responsible programs do not create it.

The steps that did work on my system:

  1. cd /etc/console-setup
  2. Find a file to use as template: ls | grep kmap (search for filenames containing 'kmap' in current folder). I choose cached_UTF-8_del.kmap.gz.
  3. Create a duplicate of the template file and call it cached.kmap.gz: sudo cp cached_UTF-8_del.kmap.gz cached.kmap.gz(except NVIDIA drivers enabled via software & updates and grub quiet splash disabled because of shutdown bug)
  4. run sudo update-initramfs -u so cached.kmap.gz can be integrated in the boot sequence.

(I tested that cached.kmap.gz whas being used by running stat cached.kmap.gz before and after step 4 and comparing the access timestamps.)

After reboot, cryptsetup would accept my LUKS pasphrase in my preferred keyboard layout, instead of QUERTY.

(That means cached_UTF-8_del.kmap.gz already contained the correct layout. If above method does not work for you, you may try your luck with one of the commands at Change keyboard layout (English UK) on command line to English US or https://apps.ubuntu.com/cat/applications/language-selector-gnome/)

I'm on kernel 4.13.0-32-generic' (check usinguname -r`). Upgrading the kernel might mitigate the issue as well, but I did not want to do that as I feared that would result in conflicts with the NVIDIA driver again. (Why I had to leave Fedora; after almost every kernel update, my system would turn unstable again, and I don't have the skills and time to solve that.)

* except NVIDIA drivers enabled via software & updates and grub quiet splash disabled because of shutdown bug

Solution 2:

KEYMAP=y is a Debian only mechanism and therefore only usable in Debian. It gets passed in /usr/share/initramfs-tools/hooks/keymap located in initramfs-tools package and generates the later used /etc/boottime.kmap.gz.

initramfs-tools in Ubuntu provides entirely different hooks and they do not use KEYMAP=y. But those scripts always try to load the configured local keymap. /usr/share/initramfs-tools/hooks/console_setup will copy the existing /etc/console-setup/cached.kmap.gz to the small busybox environment. Later /usr/share/initramfs-tools/scripts/init-top/console_setup will then load this keymap.

Btw. it seems to that /usr/share/initramfs-tools/scripts/init-top/keymap will also try to load in the same way /etc/boottome.kmap.gz, but this file do not exist (it was used in former times).

However /usr/share/initramfs-tools/hooks/console_setup do not generate /etc/console-setup/cached.kmap.gz and just use the existing one, in contrast to Debian. I assume that the generation has to do once right and then it should work again and then call ´update-initramfs -u`.

However, it seems to I was not able to do it right at that point. What worked is a bit disappointing: I had to install the whole OS again. Make sure you have selected your correct keyboard layout during the installation process and run ´update-initramfs -u` in a chroot environment of the new system after the installation process but before booting into the new installed system (I tested that btw.)