zfs icon indicating copy to clipboard operation
zfs copied to clipboard

contrib: dracut: always include zfs kernel module

Open jozzsi opened this issue 10 months ago • 4 comments

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 .

jozzsi avatar Mar 02 '25 13:03 jozzsi

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

jozzsi avatar May 29 '25 14:05 jozzsi

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.

nabijaczleweli avatar May 29 '25 15:05 nabijaczleweli

Do you have a reproducer so I can test this?

nabijaczleweli avatar May 29 '25 15:05 nabijaczleweli

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.

jozzsi avatar Jun 13 '25 06:06 jozzsi