3

I use a German keyboard layout and a luks-encrypted harddrive on my up-to-date 16.04. I could enter my luks password using my German keyboard layout with no problems until I installed the latest kernel update 4.4.0-34-generic. Now the layout is en_US for the cryptsetup on boot, but after that it's all German (e.g. for login).

I can still select to boot the old kernel 4.4.0-31-generic and have the German keyboard layout on cryptsetup.

I tried adding "KEYMAP=y" to my /etc/initramfs-tools/initramfs.conf and rebuilding my initramfs with "sudo update-initramfs -u", but that did not help.

How can I set a keyboard layout on cryptsetup with the newest kernel?

2 Answers2

3

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

c0d0g3n
  • 31
  • Instead of grepping your keymap, the far easier way is to just run: loadkeys and then dumpkeys | gzip -9 > cached.kmap.gz – SurpriseDog May 20 '19 at 22:08
3

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.)

F.Raab
  • 421
  • 4
  • 6
  • One day a few weeks ago I had a kernel update and it suddenly worked again. Without changing any config or keyboard setting. I assume it was a regression which took a few months to fix. – vollkorn Mar 21 '17 at 08:40
  • Thank you for a detailed explanation of how Ubuntu is different, that helped a lot! Because of your answer I have found this Launchpad report that had a proposed solution that worked for me: https://bugs.launchpad.net/ubuntu/+source/console-setup/+bug/1719612/comments/4 – Igor Zinov'yev Jul 26 '23 at 09:13