Dead keyboard on Linux boot
LUKS passphrase editon. Spare keyboards: 0.
After accidently installing a “Macbook HID” package targeted at quite a different generation of Macbook than I'm running, the internal keyboard became unresponsive. The keyboard was only out of order during the full-disk encryption unlock sequence, when required to supply the passphrase. After giving an external keyboard a try, it was working flawlessly which was a positive sign that the system hadn't locked-up completely. Accessing GRUB or systemd-boot before LUKS, or logging in after unlocking the disk was workng as intended. A backup keyboard seems like less overhead than a full live chroot into the system, but if no extra keyboard is available, it's possible to resolve the issue with nothing less than a bootable distro.
Keyboard issues with the boot manager or other system use are probably caused by unrelated factors than those discussed here. Their solutions may differ as well.
Apple Inc. MacBookPro 11,2, Arch Linux 5.10.8
Possible path forward
Prioritize hooks
After booting into the system (keyboard should work at this moment), have a look at mkinitcpio.conf
. On my system, it looks like so (skipping comments):
user@mbpro:/etc|⇒ cat /etc/mkinitcpio.conf | grep -v "#"
MODULES=()
BINARIES=()
FILES=()
HOOKS=(base udev autodetect modconf block encrypt filesystems keyboard shutdown fsck)
We find a couple interesting hooks:
encrypt
for the encryption andkeyboard
which is relevant to our case.autodetect
may be of interest. (SWIM recalled thatautodetect
is somewhere between critical to useful for autodetecting keyboards among other things. SWIM believesautodetect
to be much slower thanencrypt
, and could be causing the unlock sequence to start before the keyboard is ready.
Roughly speaking, the hooks are initialized in order of appearance, and not necessarily dependent on one another. We can assume a naive approach and reorder hooks according to the hypothesis “keyboard
> encrypt
”. In our current mkinitcpio.conf
, the keyboard hook is listed after encryption which seems to work out most of the time. Let's rearrange the order so that keyboard
is listed before encrypt
, and also before autodetect
:
user@mbpro:/etc|⇒ cat mkinitcpio.conf | grep -v "#"
MODULES=()
BINARIES=()
FILES=()
HOOKS=(base udev keyboard autodetect modconf block encrypt filesystems shutdown fsck)
To have the new configuration applies, run mkinitcpio
to build a new init ramdisk[1].
user@mbpro:/etc|⇒ sudo mkinitcpio -p linux
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 5.10.8-arch1-1
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [keyboard]
==> WARNING: Possibly missing firmware for module: xhci_pci
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [encrypt]
-> Running build hook: [filesystems]
-> Running build hook: [shutdown]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: 5.10.8-arch1-1
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [keyboard]
==> WARNING: Possibly missing firmware for module: xhci_pci
-> Running build hook: [modconf]
-> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: aic94xx
==> WARNING: Possibly missing firmware for module: wd719x
-> Running build hook: [encrypt]
-> Running build hook: [filesystems]
-> Running build hook: [shutdown]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback.img
==> Image generation successful
After that, reboot the system to see if the new change was the required fix. On my machine, the problem is gone, for now.
If an external keyboard doesn't work
In this thread[2] the same problem was affecting an external, usb keyboard. It could be resolved using a similar solution. Specifically here is the addition of usbinput
before the encrypt
hook:
HOOKS="base udev autodetect modconf block keyboard keymap usbinput encrypt lvm2 resume filesystems fsck"
More hooks mentioned
there is a new
hid-generic
module that has to be included now.[3]
you might need add
ehci-platform
ohci-platform
[4]
No keyboard inside
initramfs
[5]
https://www.reddit.com/r/ManjaroLinux/comments/44me83/password_prompt_encrypted_drive_with_luks_no/ ↩︎
https://www.linuxquestions.org/questions/slackware-14/non-working-usb-keyboard-at-luks-prompt-14-1-a-4175484332/#post5063136 ↩︎
https://www.linuxquestions.org/questions/slackware-14/non-working-usb-keyboard-at-luks-prompt-14-1-a-4175484332/#post5173135 ↩︎