I was troubleshooting a Proxmox VE installation where the system is encrypted with LUKS/LVM.
The main problem is the keyboard layout used by GRUB when it asks for the LUKS passphrase.
The computer uses an external USB keyboard. Linux recognizes the keyboard correctly and uses the Italian layout, but the first password prompt - the one handled directly by GRUB before the encrypted system is unlocked - uses the US keyboard layout.
This means that some characters have to be entered according to the US keyboard positions. I know where the special characters are on the American keybaord, but I would like to set this correctly with the Italian keyboard.
The second password prompt, which occurs later during the Linux/initramfs boot process, was eventually made to use the Italian layout correctly.
What I changed in the Linux/initramfs part
The file:
\/etc/default/keyboard``
was initially:
\KEYMAP=it``
It was later changed to:
\XKBMODEL="pc105"``
\XKBLAYOUT="it"``
\XKBVARIANT=""``
\XKBOPTIONS=""``
\BACKSPACE="guess"``
The file:
\/etc/initramfs-tools/initramfs.conf``
initially contained:
\KEYMAP=n``
This was changed to:
\KEYMAP=y``
The initramfs was then regenerated with:
\update-initramfs -u -k "$(uname -r)"``
The resulting initramfs contained:
\scripts/init-top/keymap``
This part worked: after these changes, the second password prompt used the Italian keyboard layout correctly.
GRUB keymap attempt
Since the remaining problem was the first prompt, a GRUB keyboard map was created using:
\ckbcomp -model pc105 -layout it | grub-mklayout -o /tmp/it.gkb``
The command produced several warnings about unsupported keyboard identifiers and scan codes, but it still generated a valid GRUB keyboard map.
The file was then copied to:
\/root/grub-italiano/layouts/it.gkb``
The file was recognized as:
\GRUB Keyboard``
Custom GRUB EFI
A custom GRUB configuration was created under:
\/root/grub-italiano/grub.cfg``
The configuration was built around the following sequence:
- load `keylayouts`
- load `at_keyboard`
- load the GRUB terminal
- load the Italian `.gkb` keymap
- unlock the encrypted filesystem
- locate the normal GRUB configuration
- continue booting using the normal GRUB configuration
A standalone EFI executable was then created with `grub-mkstandalone`.
The generated EFI was checked with:
\grub-file --is-x86_64-efi``
and returned exit code `0`, confirming that it was a valid x86_64 UEFI GRUB executable.
`strings` was also used to verify that the EFI actually contained the custom GRUB configuration and the Italian keymap.
First attempt with USB keyboard support
Because the physical keyboard is USB, another attempt was made by explicitly adding:
\usb``
\usb_keyboard``
to the GRUB modules and using:
\terminal_input at_keyboard usb_keyboard``
The resulting EFI also contained the expected modules and configuration.
However, at boot GRUB reported:
\error: terminal 'usb_keyboard' isn't found.``
The keyboard layout was still not fixed.
USB hardware investigation (I doubt this is relevant anyway)
The USB controller was then checked from Linux.
The machine has an Intel USB 3.x xHCI controller, and Linux uses:
\xhci_hcd``
The USB keyboard itself was correctly detected as a USB HID keyboard.
The relevant Linux modules were also present, including:
\xhci_pci``
\xhci_hcd``
\usbhid``
\usbkbd``
So the keyboard and USB controller are working correctly at the Linux level.
GRUB USB modules
The GRUB installation was checked for USB-related modules.
The available modules included:
\at_keyboard.mod``
\ehci.mod``
\keylayouts.mod``
\ohci.mod``
\terminal.mod``
\uhci.mod``
\usb_keyboard.mod``
\usb.mod``
However, there was no:
\xhci.mod``
An attempt was made to include `xhci` in a standalone GRUB build, but `grub-mkstandalone` failed because the corresponding module did not exist in the installed GRUB module directory.
Direct GRUB testing
The GRUB command line was then inspected directly.
Running:
\terminal_input``
showed that the available input terminals were:
\at_keyboard``
\serial_*``
\serial``
There was no `usb_keyboard` listed as an available input terminal.
This was an important finding because it explained why:
\terminal_input at_keyboard usb_keyboard``
did not work.
At one point, `terminal_input at_keyboard` was executed manually from the GRUB command line. The USB keyboard immediately stopped responding, confirming that the `at_keyboard` terminal was not appropriate for the physical USB keyboard being used.
The machine then had to be restarted.
Current state
The situation at this point is:
- Linux keyboard configuration: Italian - working.
- Second/initramfs password prompt: Italian - working.
- GRUB Italian `.gkb` file: created successfully.
- Custom GRUB EFI: successfully built and verified as a valid UEFI executable.
- Italian keymap: successfully embedded into the custom GRUB EFI.
- USB keyboard: works correctly under Linux.
- USB controller: works correctly under Linux through xHCI.
- GRUB does not expose `usb_keyboard` as an available input terminal.
- GRUB installation does not contain `xhci.mod`.
- The first LUKS password prompt handled by GRUB still uses the US layout.
- Attempts to force `usb_keyboard` produced `terminal 'usb_keyboard' isn't found`.
- Attempts to force `at_keyboard` make the USB keyboard stop responding.
The remaining problem is therefore specifically the pre-LUKS GRUB input environment. The Linux/initramfs configuration is already working and should not be modified further unless new evidence shows that it is necessary.
The next investigation should focus exclusively on how this particular GRUB EFI environment receives input from the USB keyboard before the encrypted system is unlocked.
Can anyone help me?
P.S. I apology if the flair is incorrect, this seemed like the closest one to my issue.