Skip to content

Put the USB keyboard modules in the initramfs when staging encryption - #786

Open
joshuaswarren wants to merge 2 commits into
omacom:quattrofrom
joshuaswarren:fix/encrypt-usb-keyboard-modules
Open

joshuaswarren wants to merge 2 commits into
omacom:quattrofrom
joshuaswarren:fix/encrypt-usb-keyboard-modules

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #743.

With --encrypt, the passphrase is typed at a prompt in the initramfs. On a Mac Studio (M2 Ultra) the image built by stage_worker had dwc3.ko, phy-apple-atc.ko, tps6598x*, typec.ko, xhci-*, usbhid.ko and hid-apple.ko, but not dwc3-apple.ko or apple-tunable.ko, and the USB-C keyboard was dead at the prompt (reporter's findings in #743).

Change: The drop-in checks, with modinfo -k "${KERNELVERSION:-$(uname -r)}" when mkinitcpio builds each image, which of the reporter's list the kernel being built has (apple_tunable phy_apple_atc tps6598x typec dwc3 dwc3_apple xhci_plat_hcd usbhid hid_apple hid_generic). write_usb_keyboard_dropin writes /etc/mkinitcpio.conf.d/20-omarchy-usb-keyboard.conf (a loop that does MODULES+=(...), as fix-asahi-hid-race.sh does) when encrypting, and stage_worker calls it before mkinitcpio -P. Without --encrypt nothing is written.

Tests (test/shell.d/btrfs-migrate-usb-keyboard-test.sh), written first: before the change they fail with usb_keyboard_modules: command not found. After: modules the kernel lacks are left out, encryption writes the drop-in, no encryption writes none. modinfo and uname are stubbed; only the kernel being built has the modules.

Not verified, and I have no Mac to try it on:

@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issue was found.

Summary

Adds a persistent USB keyboard module drop-in when staging encryption.

  • Encrypted migrations include available USB keyboard drivers in initramfs images.

The earlier running-kernel finding is addressed: module checks now happen inside the generated drop-in and use KERNELVERSION.

Reviews (3) · Last reviewed commit: "Check the USB keyboard modules for the k..." · Reviewed by Greptile

Comment thread bin/omarchy-system-btrfs-migrate Resolved
joshuaswarren added a commit to joshuaswarren/omacom-omarchy that referenced this pull request Nov 3, 2026
Greptile on omacom#786: after a kernel update without a reboot, modinfo for the running kernel finds nothing and the drop-in was skipped, though mkinitcpio builds the installed kernel image. The drop-in now holds the check itself and runs it when each image is built, with KERNELVERSION, as fix-asahi-hid-race.sh does. Test: only the kernel being built has the modules and the running kernel has none; the drop-in adds them for the first, none for another kernel.
@joshuaswarren

Copy link
Copy Markdown
Collaborator Author

[Joshua's agent] Greptile's P1 addressed in 191def0c8: the drop-in no longer decides at staging time. It carries the check and runs it when mkinitcpio builds each image, with ${KERNELVERSION:-$(uname -r)}, as fix-asahi-hid-race.sh does, so a kernel update without a reboot builds its image for its own kernel. The test now has only the kernel being built provide the modules (the running kernel has none) and asserts they are added for it, tps6598x is left out when missing, and another kernel gets none. The PR text said the list is checked with modinfo against the running kernel; that is now the kernel being built. Install VM on this head fails with the hyprtoolkit error until #787 merges.

The passphrase prompt runs in the initramfs, so a USB keyboard only works there if the USB-C controller and HID modules are in the image. On a Mac Studio (omacom#743) dwc3_apple and apple_tunable were missing and the keyboard was dead at the prompt. With encryption, staging now writes /etc/mkinitcpio.conf.d/20-omarchy-usb-keyboard.conf with the modules this kernel has (checked with modinfo) before it rebuilds the initramfs. Test: modules the kernel lacks are left out, encryption writes the drop-in, no encryption writes none.
Greptile on omacom#786: after a kernel update without a reboot, modinfo for the running kernel finds nothing and the drop-in was skipped, though mkinitcpio builds the installed kernel image. The drop-in now holds the check itself and runs it when each image is built, with KERNELVERSION, as fix-asahi-hid-race.sh does. Test: only the kernel being built has the modules and the running kernel has none; the drop-in adds them for the first, none for another kernel.
@joshuaswarren
joshuaswarren force-pushed the fix/encrypt-usb-keyboard-modules branch from 191def0 to c6396c0 Compare November 3, 2026 13:33
@joshuaswarren

Copy link
Copy Markdown
Collaborator Author

🤖 Claude Haiku 5.5 responding on behalf of joshuawarren

Still needed: quattro (PR base at 7cb792e) has no USB keyboard modules in the initramfs when encryption is staged. Without them a USB keyboard is dead at the passphrase prompt (issue #743). This adds them only when encryption is set up, and only for kernels that have each module. Checks are green and the PR is mergeable. Could a maintainer review it?

[Joshua's agent]

@joshuaswarren

Copy link
Copy Markdown
Collaborator Author

GREEN at c6396c0

[Joshua's agent] Reviewed the two-file change and its integration into stage_worker.

The drop-in is created only for encryption, before mkinitcpio -P. It appends rather than replaces existing MODULES, checks availability against KERNELVERSION for the image being built, and finishes successfully when a listed module is unavailable. The pattern matches the existing Apple HID drop-in. Checked current upstream mkinitcpio source: kernel-version resolution precedes config/drop-in loading; custom-config presets may bypass the default drop-in directory.

The focused shell regression passes all four checks: no plaintext-mode write, encryption drop-in creation, build-kernel rather than running-kernel module selection with existing modules preserved, and successful empty selection when none are available. No blocking findings.

Limits: no real keyboard/initramfs/boot test, encrypted migration or device access. The PR explicitly does not verify the generated image with lsinitcpio, isolate the minimal driver set, or establish a fix for other keyboard paths. An image-content check and a real passphrase-prompt test remain necessary before claiming hardware confirmation.

Reviewer: Codex GPT-6.1 Sol as routed by Main (model id unverifiable); implementer model unverified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant