contrib: dracut: always include zfs kernel module
This commit fixes the issue and includes the zfs kernel module even when dracut is used in hostonly mode.
Motivation and Context
Sometimes zfs kernel module is not included in the dracut generated initrd. One way this can happen if zfs kernel module is not loaded at the time of initrd generation and dracut is instructed to build hostonly initrd (which is the default in some Linux distributions).
This change would also eliminate the need for the following additional step/workaround in using zfs dracut module
echo 'force_drivers+=" zfs "' >> /etc/dracut.conf.d/zfs.conf
Description
Ignore the hostonly setting when zfs kernel module is installed. This is a well established pattern in dracut modules - see e.g. https://github.com/dracut-ng/dracut-ng/blob/main/modules.d/90overlayfs/module-setup.sh#L13
How Has This Been Tested?
Run into this issue working on a dracut patch and needed to work around this bug in the dracut CI .
instmods will not install the kernel module, if $hostonly is set and the kernel module is not currently needed. To install a kernel module regardless of the hostonly mode use the form:
hostonly='' instmods <kernelmodule>
See https://dracut-ng.github.io/dracut-ng/man/dracut.modules.7.html#_inst_libdir_file_n_pattern_o_file_file
CC @nabijaczleweli
This is A/B. If the module isn't detected as used, then fix the detection instead of breaking a rdep of the detection. It worked when I last touched this and it works on bookworm and sid, so.
Do you have a reproducer so I can test this?
To reproduce, you need to somehow have zfs module not loaded on the host at the time dracut is called to generate initramfs (but zfs dracut module should be installed ion the host) and you need to remove the '/etc/dracut.conf.d/zfs.conf' workaround.
As mentioned in the first post the following step should not be necessary for a well functioning dracut module
echo 'force_drivers+=" zfs "' >> /etc/dracut.conf.d/zfs.conf
Perhaps the repro case is the reason why this workaround has been added for the documentation.