Dracut complains that `--kmoddir /lib/modules/...` doesn't have "/lib/modules" as a parent directory.
Describe the bug
Dracut doesn't see /lib/modules/ in the kmoddir and complains, but it is infact there in the path.
Distribution used Arch (updated today)
Dracut version 055
Init system systemd 249 (249.4-1-arch)
To Reproduce
> sudo dracut --kernel-image /boot/vmlinuz-linux --kmoddir /lib/modules/5.14.5-arch1-1/
dracut: -k/--kmoddir path must contain "lib/modules" as a parent of your kernel module directory,
dracut: or modules may not be placed in the correct location inside the initramfs.
dracut: was given: /lib/modules/5.14.5-arch1-1/
dracut: expected: /lib/modules/lib/modules/5.13.5-arch1-1
dracut: Please move your modules into the correct directory structure and pass the new location,
dracut: or set DRACUT_KMODDIR_OVERRIDE=1 to ignore this check.
Expected behavior Typing a kmoddir that includes "lib/modules" should be accepted and not duplicate into "lib/modules/lib/modules"
Additional context I upgraded to the latest kernel and have not yet rebooted the system. I'd like to gen an initramfs before rebooting. I wonder if dracut is confused because I'm telling it to build an image for 5.14 but am running 5.13...
This bug is primarily an issue with the error message. It should say that dracut is explicitly looking for a 5.13 module directory because the active kernel is 5.13, despite being told explicit --kernel-image and --kmoddir flags.
It would be more useful to say:
dracut: The provided kernel image version is 5.14.5 which does not match the actively running 5.13.5 kernel. To build
dracut: an initramfs for this version use `--kver 5.14.5` as an argument.
Or something. This kind of advise could cause other confusion, so I'll defer to those who are more familiar with the nuances of mixing kernel/module versions
dracut only recognizes the path to the /lib/modules directory that matches the active kernel version, otherwise it will regard the kmoddir as a subdirectory under /lib/modules/$(uname) and try to find it.
The warning message seems confusing and is expected to be improved.