Skip to contentSkip to conversation

Correctly handle module aliases

PATCH In review Fabian Vogt 2 participants 2 messages Jan 21, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Correctly handle module aliases

Handle module aliases correctly to not generate unbootable initrds with different kernel versions when modules were renamed or replaced.

---

This is the case for mpt3sas -> mpt2sas migration in kernel 4.4, which caused issues like https://bugzilla.opensuse.org/show_bug.cgi?id=962694

 dracut.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
dracut.sh +21 -0
index 98dbe0b..ae8772b 100755
@@ -1195,6 +1195,27 @@ if [[ $hostonly ]]; then
     while read m rest || [ -n "$m" ]; do
         host_modules["$m"]=1
     done </proc/modules
+
+    # Explanation of the following section:
+    # Since kernel 4.4, mpt3sas is a complete replacement for mpt2sas.
+    # mpt3sas has an alias to mpt2sas now, but since mpt3sas isn't loaded
+    # when generating the initrd from kernel < 4.4, it's not included.
+    # The other direction has the same issue:
+    # When generating the initrd from kernel >= 4.4, mpt2sas isn't loaded,
+    # so it's not included.
+    # Both ways result in an unbootable initrd.
+
+    # also add aliases of loaded modules
+    for mod in "${!host_modules[@]}"; do
+        aliases=$(modinfo -F alias "$mod" 2>&1)
+        for alias in $aliases; do
+            host_modules["$alias"]=1
+        done
+        # mod might be an alias in the target kernel, find the real module
+        mod_filename=$(modinfo -k "$kernel" "$mod" -F filename)
+        [ $? -ne 0 ] && continue
+        host_modules["$(basename -s .ko "$mod_filename")"]=1
+    done
 fi
 
 unset m
Signature · 1 line
2.7.0

A message that is not in the archive (sent off-list or not yet received): [email protected]