Skip to content

m42a/linux-keep-kernel-modules

Repository files navigation

Keep Kernel Modules

A tool for keeping kernel modules around after kernel updates. Unlike kernel-modules-hook and linux-keep-modules, the modules are kept in a temporary mount, so no manual cleanup after reboot is needed. On the other hand, this means the modules will occupy RAM until the files are unmounted or the system is rebooted.

Automatic usage (Arch Linux only)

Run makepkg in the checkout directory, and install the created package. This will automatically back up your modules when the kernel is upgraded.

Manual Usage (all distros)

  1. As root, run the current-modules-tmpfs.sh script to back up your kernel modules to /lib/current-modules. To manually load modules, you can run modprobe -d /lib/current-modules $module_name.
  2. To allow automatic module loading (e.g. by udev when plugging in new hardware) run the current-modules-overlay.sh script as root. This will overlay the backed up modules onto the regular modules directory, allowing scripts to use modprobe without specifying a custom module directory.
  3. To undo the effects of the overlay script, run umount current-modules-overlay. To undo the effects of the tmpfs script, run umount current-modules. Unmounting the overlay is non-destructive, and it can be remounted by re-running the current-modules-overlay.sh script. Unmounting the tmpfs will discard the modules saved in RAM. If the modules have already been removed from the main filesystem, they will need to be restored before the tmpfs can be recreated.

Technical Notes

Custom module directories

By default, kernel modules are stored in /lib/modules. If your modprobe uses a different directory, you will need to install pkg-config to allow the script to detect the new location. The modules directory is listed in the output of modprobe --help.

tmpfs immutability

After being populated, the tmpfs is recursively marked as immutable. This prevents you from accidentally removing or changing any of them. This is especially important when the overlay is mounted, since modifying the current modules directory will create files on disk which will need to be manually cleaned up.

About

Keep kernel modules around after kernel updates.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages