#1132934 molly-guard: check for required modules in initrd before reboot/shutdown

#1132934#5
Date:
2026-04-07 18:21:39 UTC
From:
To:
Dear Maintainer,

== Summary ==

I wrote a molly-guard script to prevent reboot/halt when the current
/initrd.img does not contain some configured kernel modules.

The modules to check can be configured in the script.

Would you please consider adding the attached script to the molly-
guard package as an example in /usr/share/doc/molly-guard/examples?


== Why I wrote this script ==

I am using "ZFS on root" on Debian, which means that GRUB directly
boots from a ZFS filesystem.  I don't have any non-ZFS filesystems on
my systems (apart from /boot/efi which needs to be FAT).

Because of the license situation regarding ZFS, the kernel modules
cannot directly be provided by Debian and thus need to be compiled
locally using DKMS.

Very infrequently something can go wrong during either the compilation
of the modules or the subsequent inclusion of the kernel modules into
the initrd.¹  This will then make the system unbootable, which I will
only find out on the next boot.

To prevent the modules from missing on boot, I have written the
attached molly-guard run script to check the latest /initrd.img for
the expected modules.  If they are not present, a reboot or halt will
be prevented.


== Why I think this is useful for others ==

The module(s) to check can be easily edited in the script, so this
should be adaptable to other scenarios apart from ZFS on root, eg.
vital kernel modules for network or storage hardware.

I was encouraged to submit the script as a whishlist bug during a
discussion on Usenet, so here I am.



Kind regards
Christian

PS: Thanks for this package!
    It has saved me multiple times from shutting down the wrong server
    (which happens more often than broken ZFS modules nowadays ;-)