Subject: [bug#30604] [PATCH v11 5/6] linux-initrd: Provide our own 'modprobe' program.

From: [email-masked] (Ludovic Courtès)
Date: Tue, 13 Mar 2018 09:50:40 +0100

Hello!

I’m using this on the bare metal.  \o/

I had to make this change so that dm-crypt would be loaded once I’ve
entered my passphrase:

diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 7a167146f..ef81fe718 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -115,16 +115,19 @@ when modules need to be loaded."
             (current-error-port (%make-void-port "w"))
             (current-output-port (%make-void-port "w")))
 
-          (let ((modules (matching-modules alias %known-aliases)))
+          ;; Look up ALIAS in %KNOWN-ALIASES first, and then, if it fails,
+          ;; assume that ALIAS is a module name (some modules such as
+          ;; 'dm-crypt' don't have an alias.)  Note that
+          ;; 'kmod_module_new_from_lookup' uses a different search order.
+          (let ((modules (match (matching-modules alias %known-aliases)
+                           (()  (list alias))
+                           (lst lst))))
             (call-with-output-file "/dev/kmsg"
               (lambda (port)
                 (setvbuf port 'block 1024)
                 (format port "modprobe[~a]: alias ~s; modules ~s; args ~s~%"
                         (getpid) alias modules (program-arguments))))
 
-            (when (null? modules)
-              (error "alias resolution failed" alias))
-
             (load-linux-modules-from-directory modules
                                                linux-module-directory)))))

FWIW I have:

--8<---------------cut here---------------start------------->8---
modprobe[146]: alias "net-pf-38"; modules ("net-pf-38"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "net-pf-38")
modprobe[152]: alias "dm-crypt"; modules ("dm-crypt"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "dm-crypt")
modprobe[157]: alias "crypto-xts(aes)"; modules ("crypto-xts(aes)"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-xts(aes)")
modprobe[162]: alias "crypto-xts(aes)-all"; modules ("crypto-xts(aes)-all"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-xts(aes)-all")
modprobe[168]: alias "crypto-xts"; modules ("xts"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-xts")
nfo>  [1520929735.4127] manager[0x12950c0]: monitoring kernel firmware directory '/lib/firmware'.
modprobe[173]: alias "crypto-aes"; modules ("crypto-aes"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-aes")
modprobe[178]: alias "crypto-aes-all"; modules ("crypto-aes-all"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-aes-all")
modprobe[183]: alias "crypto-ecb(aes)"; modules ("crypto-ecb(aes)"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-ecb(aes)")
modprobe[188]: alias "crypto-ecb(aes)-all"; modules ("crypto-ecb(aes)-all"); args ("/gnu/store/v0ay302yib6j6ysr0pd1yphm00nlzkxh-modprobe" "-q" "--" "crypto-ecb(aes)-all")
--8<---------------cut here---------------end--------------->8---

Something annoying is that my external USB keyboard doesn’t work while
in the initrd (when I type my passphrase).  I can see that it’s detected
early on, before I type my passphrase:

--8<---------------cut here---------------start------------->8---
[    1.532237] usb 1-4.2: new low-speed USB device number 4 using xhci_hcd
[    1.648836] usb 1-4.2: New USB device found, idVendor=413c, idProduct=2105
[    1.649189] usb 1-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    1.649533] usb 1-4.2: Product: Dell USB Keyboard
[    1.649882] usb 1-4.2: Manufacturer: Dell
--8<---------------cut here---------------end--------------->8---

but its modules don’t get loaded until after eudev has been started, and
there’s no trace of a modprobe invocation for it.

--8<---------------cut here---------------start------------->8---
[   20.968938] input: Dell Dell USB Keyboard as /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.2/1-4.2:1.0/0003:413C:2105.0001/input/input16
--8<---------------cut here---------------end--------------->8---

Any idea what we’re missing?

Thanks,
Ludo’.