|
|
0903d0 |
From 8df75b15736b2feaea05fd45d3b4819775226ee5 Mon Sep 17 00:00:00 2001
|
|
|
0903d0 |
From: Kairui Song <kasong@redhat.com>
|
|
|
0903d0 |
Date: Tue, 17 Jul 2018 17:16:07 +0800
|
|
|
0903d0 |
Subject: [PATCH] Record loaded kernel modules when hostonly mode is enabled
|
|
|
0903d0 |
|
|
|
0903d0 |
A hostonly image will not include every possibly required kernel module,
|
|
|
0903d0 |
so if any hardware or configuration changed, the image may fail to boot.
|
|
|
0903d0 |
|
|
|
0903d0 |
One way to know if there are any hardware change or configuration change
|
|
|
0903d0 |
that will require an image rebuild or not is to check the loaded kernel
|
|
|
0903d0 |
module list. If the loaded kernel module list differs from last build
|
|
|
0903d0 |
time, then the image may require to be rebuilt.
|
|
|
0903d0 |
|
|
|
0903d0 |
This commit will let dracut record the loaded kernel module list when
|
|
|
0903d0 |
the image is being built, so other tools or services can compare this
|
|
|
0903d0 |
list with currently loaded kernel modules to decide if dracut should be
|
|
|
0903d0 |
called to rebuild the image.
|
|
|
0903d0 |
|
|
|
0903d0 |
To retrieve the loaded kernel modules list when an image is built, use
|
|
|
0903d0 |
lsinitrd command:
|
|
|
0903d0 |
|
|
|
0903d0 |
lsinitrd $image -f */lib/dracut/loaded-kernel-modules.txt
|
|
|
0903d0 |
|
|
|
0903d0 |
Cherry-picked from: 7047294617bbdd3ffb2466c73db56fda4e6156db
|
|
|
0903d0 |
Resolves: #1607744
|
|
|
0903d0 |
---
|
|
|
0903d0 |
dracut-functions.sh | 11 +++++++++++
|
|
|
0903d0 |
dracut.sh | 3 +++
|
|
|
0903d0 |
2 files changed, 14 insertions(+)
|
|
|
0903d0 |
|
|
|
0903d0 |
diff --git a/dracut-functions.sh b/dracut-functions.sh
|
|
|
0903d0 |
index 53289ca0..b7568bd9 100755
|
|
|
0903d0 |
--- a/dracut-functions.sh
|
|
|
0903d0 |
+++ b/dracut-functions.sh
|
|
|
0903d0 |
@@ -1748,6 +1748,17 @@ get_ucode_file ()
|
|
|
0903d0 |
fi
|
|
|
0903d0 |
}
|
|
|
0903d0 |
|
|
|
0903d0 |
+# Get currently loaded modules
|
|
|
0903d0 |
+# sorted, and delimited by newline
|
|
|
0903d0 |
+get_loaded_kernel_modules ()
|
|
|
0903d0 |
+{
|
|
|
0903d0 |
+ local modules=( )
|
|
|
0903d0 |
+ while read _module _size _used _used_by; do
|
|
|
0903d0 |
+ modules+=( "$_module" )
|
|
|
0903d0 |
+ done <<< $(lsmod | sed -n '1!p')
|
|
|
0903d0 |
+ printf '%s\n' "${modules[@]}" | sort
|
|
|
0903d0 |
+}
|
|
|
0903d0 |
+
|
|
|
0903d0 |
# Not every device in /dev/mapper should be examined.
|
|
|
0903d0 |
# If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
|
|
|
0903d0 |
lvm_internal_dev() {
|
|
|
0903d0 |
diff --git a/dracut.sh b/dracut.sh
|
|
|
0903d0 |
index a34ca2a6..245b4c49 100755
|
|
|
0903d0 |
--- a/dracut.sh
|
|
|
0903d0 |
+++ b/dracut.sh
|
|
|
0903d0 |
@@ -1395,6 +1395,9 @@ dinfo "*** Including modules done ***"
|
|
|
0903d0 |
|
|
|
0903d0 |
## final stuff that has to happen
|
|
|
0903d0 |
if [[ $no_kernel != yes ]]; then
|
|
|
0903d0 |
+ if [[ $hostonly ]]; then
|
|
|
0903d0 |
+ echo "$(get_loaded_kernel_modules)" > $initdir/lib/dracut/loaded-kernel-modules.txt
|
|
|
0903d0 |
+ fi
|
|
|
0903d0 |
|
|
|
0903d0 |
if [[ $drivers ]]; then
|
|
|
0903d0 |
hostonly='' instmods $drivers
|