[PR #76] initramfs-tools: load nvidia-drm in the initramfs right after gpu_unlock #137

Open
opened 2026-10-26 16:41:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Zagitta/gpu-unlock/pull/76
Author: @soltia48
Created: 10/25/2026
Status: 🔄 Open

Base: main ← Head: initramfs-tools-nvidia-drm


📝 Commits (2)

  • 68a224c initramfs-tools: load nvidia-drm right after gpu_unlock
  • 620ebe1 initramfs-tools: load nvidia_drm from an init-premount script

📊 Changes

5 files changed (+149 additions, -2 deletions)

View changed files

📝 Makefile (+4 -0)
📝 README.md (+20 -2)
➕ packaging/boot/initramfs-tools-hook (+47 -0)
➕ packaging/boot/initramfs-tools-premount (+23 -0)
📝 tests/test_packaging.py (+55 -0)

📄 Description

Problem

On a display card, gpu_unlock removes the firmware framebuffer
(simpledrm/efifb) just before the card's FLR, and nothing is shown again
until nvidia-drm loads. On Ubuntu the prebuilt nvidia modules
(linux-modules-nvidia-*, under kernel/nvidia-*) are not in the
initramfs, so nvidia-drm only loads from the root filesystem.

With an encrypted root, the LUKS passphrase prompt comes before that, on a
blank screen. The boot looks hung, and nothing reaches the journal because
the root filesystem is never mounted. Typing the passphrase blind does
boot, with the card unlocked.

Seen on Ubuntu 26.04, kernel 7.0.0-38, nvidia-driver-595-open, RTX 3080
(10de:2206) as the only card, LUKS + LVM root.

Change

  • Hook /usr/share/initramfs-tools/hooks/gpu-unlock: for a kernel
    that has both gpu_unlock and nvidia, adds nvidia_drm (and with it
    nvidia_modeset, nvidia and their firmware) to the image, and
    blacklists the three modules in etc/modprobe.d/gpu-unlock.conf inside
    the image only. udev's coldplug in init-top runs before
    /conf/modules is read and would otherwise load nvidia/nvidia_drm
    by their PCI aliases, binding the card before gpu_unlock sees it.
  • Script /usr/share/initramfs-tools/scripts/init-premount/gpu-unlock:
    loads nvidia_drm. init-premount runs after load_modules (where
    gpu_unlock runs) and before local-top/cryptroot asks for the
    passphrase.
    • It cannot go in /conf/modules: /init exports
      MODPROBE_OPTIONS="-qb", so every modprobe in the initramfs applies
      the blacklist and fails without a message. The script unsets
      MODPROBE_OPTIONS first.
    • It is unset rather than emptied: kmod 34 aborts with
      *** buffer overflow detected *** on an empty MODPROBE_OPTIONS.
    • It does nothing in an image without the hook's blacklist, that is,
      for a kernel without nvidia.
  • README: describes the hook and the script, and what to do with
    mkinitcpio and dracut, which this PR does not change.
  • Tests: the hook adds nvidia_drm, writes the blacklist and leaves
    /conf/modules alone; the script loads nvidia_drm without
    MODPROBE_OPTIONS when run with -qb, and does nothing without the
    blacklist; both are installed executable.

Only the Debian package uses initramfs-tools; RPM (dracut) and Arch
(mkinitcpio) packaging is unchanged.

Cost

Each initramfs grows by about 90 MB (165 MB to 256 MB here), most of it
the driver's GSP firmware (gsp_ga10x.bin, gsp_tu10x.bin). Check the
free space on /boot.

Testing

  • make test
  • Built an image with mkinitramfs and checked it: the nvidia modules
    and firmware are in it, the blacklist is in etc/modprobe.d, and the
    script is in init-premount/ORDER
  • In a chroot of that image, with MODPROBE_OPTIONS=-qb as at boot:
    modprobe nvidia_drm loads nothing (reproduces the original failure),
    and the script loads nvidia → nvidia-modeset → nvidia-drm modeset=1
  • On hardware, with the blacklist only: udev did not load nvidia in
    the initramfs (kernel log and /run/initramfs/initramfs.debug)
  • On hardware, with the script: the LUKS prompt is visible after the
    unlock, and journalctl -k -b | grep gpu_unlock shows unlocked

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Zagitta/gpu-unlock/pull/76 **Author:** [@soltia48](https://github.com/soltia48) **Created:** 10/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `initramfs-tools-nvidia-drm` --- ### 📝 Commits (2) - [`68a224c`](https://github.com/Zagitta/gpu-unlock/commit/68a224cb3358c71228aea8b08c1702820badebe7) initramfs-tools: load nvidia-drm right after gpu_unlock - [`620ebe1`](https://github.com/Zagitta/gpu-unlock/commit/620ebe1065f4c87806fe87f1f6ccb7f7c0ec2ab1) initramfs-tools: load nvidia_drm from an init-premount script ### 📊 Changes **5 files changed** (+149 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Makefile` (+4 -0) 📝 `README.md` (+20 -2) ➕ `packaging/boot/initramfs-tools-hook` (+47 -0) ➕ `packaging/boot/initramfs-tools-premount` (+23 -0) 📝 `tests/test_packaging.py` (+55 -0) </details> ### 📄 Description ## Problem On a display card, gpu_unlock removes the firmware framebuffer (simpledrm/efifb) just before the card's FLR, and nothing is shown again until nvidia-drm loads. On Ubuntu the prebuilt nvidia modules (`linux-modules-nvidia-*`, under `kernel/nvidia-*`) are not in the initramfs, so nvidia-drm only loads from the root filesystem. With an encrypted root, the LUKS passphrase prompt comes before that, on a blank screen. The boot looks hung, and nothing reaches the journal because the root filesystem is never mounted. Typing the passphrase blind does boot, with the card unlocked. Seen on Ubuntu 26.04, kernel 7.0.0-38, nvidia-driver-595-open, RTX 3080 (`10de:2206`) as the only card, LUKS + LVM root. ## Change - **Hook** `/usr/share/initramfs-tools/hooks/gpu-unlock`: for a kernel that has both gpu_unlock and nvidia, adds `nvidia_drm` (and with it `nvidia_modeset`, `nvidia` and their firmware) to the image, and blacklists the three modules in `etc/modprobe.d/gpu-unlock.conf` inside the image only. udev's coldplug in `init-top` runs before `/conf/modules` is read and would otherwise load `nvidia`/`nvidia_drm` by their PCI aliases, binding the card before gpu_unlock sees it. - **Script** `/usr/share/initramfs-tools/scripts/init-premount/gpu-unlock`: loads `nvidia_drm`. `init-premount` runs after `load_modules` (where gpu_unlock runs) and before `local-top/cryptroot` asks for the passphrase. - It cannot go in `/conf/modules`: `/init` exports `MODPROBE_OPTIONS="-qb"`, so every modprobe in the initramfs applies the blacklist and fails without a message. The script unsets `MODPROBE_OPTIONS` first. - It is unset rather than emptied: kmod 34 aborts with `*** buffer overflow detected ***` on an empty `MODPROBE_OPTIONS`. - It does nothing in an image without the hook's blacklist, that is, for a kernel without nvidia. - **README**: describes the hook and the script, and what to do with mkinitcpio and dracut, which this PR does not change. - **Tests**: the hook adds `nvidia_drm`, writes the blacklist and leaves `/conf/modules` alone; the script loads `nvidia_drm` without `MODPROBE_OPTIONS` when run with `-qb`, and does nothing without the blacklist; both are installed executable. Only the Debian package uses initramfs-tools; RPM (dracut) and Arch (mkinitcpio) packaging is unchanged. ## Cost Each initramfs grows by about 90 MB (165 MB to 256 MB here), most of it the driver's GSP firmware (`gsp_ga10x.bin`, `gsp_tu10x.bin`). Check the free space on `/boot`. ## Testing - [x] `make test` - [x] Built an image with `mkinitramfs` and checked it: the nvidia modules and firmware are in it, the blacklist is in `etc/modprobe.d`, and the script is in `init-premount/ORDER` - [x] In a chroot of that image, with `MODPROBE_OPTIONS=-qb` as at boot: `modprobe nvidia_drm` loads nothing (reproduces the original failure), and the script loads `nvidia` → `nvidia-modeset` → `nvidia-drm modeset=1` - [x] On hardware, with the blacklist only: udev did not load nvidia in the initramfs (kernel log and `/run/initramfs/initramfs.debug`) - [x] On hardware, with the script: the LUKS prompt is visible after the unlock, and `journalctl -k -b | grep gpu_unlock` shows `unlocked` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Zagitta/gpu-unlock#137
No description provided.