]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Correctly handle module aliases 123/head
authorFabian Vogt <fvogt@suse.com>
Thu, 21 Jan 2016 16:13:07 +0000 (17:13 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 21 Jan 2016 17:02:40 +0000 (18:02 +0100)
Handle module aliases correctly to not generate unbootable
initrds with different kernel versions when modules were renamed
or replaced.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
dracut.sh

index 98dbe0bcc2594374a281bc2a4d9f17b07ec8ef28..ae8772b40503dc30b36ddaf7c67c09db0b765054 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -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