check_kernel_module calls modprobe and tries to dry-run a module load to
check if a module is available. modprobe supports `-d` to specify a
rootdir, so just pass dracutsysrootdir to it to make it work as expected
when building initramfs for another rootfs.
Signed-off-by: Kairui Song <kasong@tencent.com>
# 0 if the kernel module is either built-in or available
# 1 if the kernel module is not enabled
check_kernel_module() {
- modprobe -S "$kernel" --dry-run "$1" &> /dev/null || return 1
+ modprobe -d "$dracutsysrootdir" -S "$kernel" --dry-run "$1" &> /dev/null || return 1
}
# get_cpu_vendor