8

I installed grub on a EFI based system. So I have the EFI partition on /dev/sdc2 and my LUKS container in /dev/sdc5. I have only one linux partition in the LUKS container. So even /boot with the stage 2 of grub is encrypted.

When the system boots the EFI boots the grub entry and grub stage 1 loads. This tries to open the LUKS container in /dev/sdc5 and wants a password.

This is the time where I want to have a german layout instead of the english-us one. I know how to change the layout in grub stage 2 but how do I change it in stage 1. Is this even possible?

OS is Debian Jessie.

XenGi
  • 83
  • 1
  • 1
  • 6
  • Have you seen this? http://forums.debian.net/viewtopic.php?f=16&t=76833 – MariusMatutiae Sep 18 '15 at 16:27
  • @MariusMatutiae This seems to be about stage 2 of grub. That's the easy part. My problem is that I use GRUB to unlock my LUKS partition. This is done by stage 1 which sits in the MBR of your harddrive and is only around 500 bytes big. – XenGi Sep 21 '15 at 14:49
  • There's an instruction in the arch wiki that claims to work: [ArchWiki - Custom keyboard layout](https://wiki.archlinux.org/index.php/Talk:GRUB#Custom_keyboard_layout) – 1125 Oct 08 '16 at 21:12
  • Grub2 has no "stage 1" or "stage 2". That was how legacy grub worked. – psusi Mar 14 '17 at 13:05
  • @psusi sorry but that's wrong. Grub2 has stage 1, 1.5 and 2. It's in the documentation. – XenGi Mar 14 '17 at 13:53
  • @XenGi, you are reading the wrong docs then. The docs for grub2 are explicitly clear that these no longer have meaning in grub2. Grub2 calls the main executable grub core, which can be only roughly compared to stage 2 in grub legacy, and for a bios booting machine ( but not for EFI like you have ) there is necessarily still the MBR, which grub legacy called stage1, but there is no stage 1.5. – psusi Mar 14 '17 at 13:56
  • 1
    Maybe they aren't called that anymore but there are still two parts of grub. The one that loads before the decryption and the one after. And in a bios setup this should be basically the same as stage 1 and 2. For UEFI you have more space so the grub binary in your ESP can do a lot more stuff. – XenGi Mar 14 '17 at 13:59

2 Answers2

5

Since you're using EFI with an encrypted /boot, I'm assuming you're already familiar with grub-mkstandalone

Add in /etc/default/grub :

GRUB_TERMINAL_INPUT=at_keyboard

Add in /etc/grub.d/40_custom :

insmod keylayouts
keymap /boot/grub/de.gkb

Next run grub-kbdcomp -o /tmp/de.gkb de to generate the german grub layout.

Now all you need to do is add "boot/grub/de.gkb=/tmp/de.gkb" to your grub-mkstandalone command. In my case it looks like this:

grub-mkstandalone -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi --compress="xz" --modules="part_gpt part_msdos crypto cryptodisk luks disk diskfilter lvm" --fonts="unicode" -o "/boot/efi/EFI/linux/grubx64.efi" "boot/grub/grub.cfg=/tmp/grub.cfg" "boot/grub/de.gkb=/tmp/de.gkb"
Darky
  • 66
  • 1
  • 4
  • So this generate an UEFI binary with grub and the defined layout? That's pretty cool thx! – XenGi Mar 14 '17 at 13:49
  • Yes. You can also use this to include background images etc (if you want to personalize your grub menu). – Darky Mar 14 '17 at 14:33
3

It cannot be done, see this Introduction to Grub2 which states explicitly:

Important: Keyboard Layout during the Boot Procedure

The US keyboard layout is the only one available when booting

MariusMatutiae
  • 46,990
  • 12
  • 80
  • 129
  • This can't work because the kernel and initramfs is on the encrypted partition and not accessible until the drive is unlocked. That's not even a solution if I would be in stage 2. – XenGi Sep 22 '15 at 23:31
  • thx, haven't seen this in the docs. – XenGi Sep 23 '15 at 10:07
  • I think this is outdated because I'm currently trying to set my grub _back_ to the US layout from us-dvorak. – pyansharp Mar 04 '22 at 04:21