Kernel Modules
Kernel modules are loadable drivers and extensions that the Linux kernel can load and unload at runtime without rebooting. On Shani OS, module configuration files placed in /etc/modules-load.d/ and /etc/modprobe.d/ live in the /etc overlay and persist across all OS updates and rollbacks.
Listing and Inspecting Modules
# List all currently loaded modules
lsmod
# Show information about a module (description, parameters, dependencies)
modinfo kvm
modinfo iwlwifi
modinfo nvidia
# Show only specific fields
modinfo -F filename kvm # path to the .ko file
modinfo -F parm kvm # available parameters
modinfo -F depends kvm # dependencies
# Check if a module is loaded
lsmod | grep kvm
Loading and Unloading Modules
# Load a module (for the current session only)
sudo modprobe kvm
sudo modprobe kvm_intel # or kvm_amd depending on CPU
# Load with parameters
sudo modprobe iwlwifi 11n_disable=1
sudo modprobe usbcore autosuspend=1
# Unload a module
sudo modprobe -r kvm_intel
sudo rmmod kvm_intel # alternative, does not handle dependencies
# Unload a module and all its dependents
sudo modprobe -r --remove-dependencies kvm_intel
# Dry run — show what would be loaded/unloaded
sudo modprobe --dry-run kvm
⚠️rmmodfails if the module is in use. Usemodprobe -rwhich handles the dependency chain, or check what is using it withlsmod | grep <module>and look at the "Used by" column.
Persistent Module Loading
To load a module automatically at boot, create a file in /etc/modules-load.d/. Files here are processed by systemd-modules-load.service early in the boot sequence.
# Load a single module at boot
echo "kvm_intel" | sudo tee /etc/modules-load.d/kvm.conf
# Load multiple modules
sudo tee /etc/modules-load.d/virtualisation.conf << 'EOF'
kvm
kvm_intel
vhost_net
EOF
Each file should contain one module name per line. Comments starting with # are ignored.
# Verify the service loaded all modules correctly
systemctl status systemd-modules-load.service
journalctl -u systemd-modules-load.service
Module Parameters
Module parameters can be set persistently in /etc/modprobe.d/.
# Disable 802.11n (workaround for some Wi-Fi issues)
echo "options iwlwifi 11n_disable=1" | sudo tee /etc/modprobe.d/iwlwifi.conf
# Set KVM nested virtualisation
echo "options kvm_intel nested=1" | sudo tee /etc/modprobe.d/kvm.conf
echo "options kvm_amd nested=1" | sudo tee /etc/modprobe.d/kvm.conf # AMD
# Set USB autosuspend delay
echo "options usbcore autosuspend=5" | sudo tee /etc/modprobe.d/usb.conf
# Verify active parameters for a loaded module
cat /sys/module/kvm_intel/parameters/nested
cat /sys/module/iwlwifi/parameters/11n_disable
Changes to /etc/modprobe.d/ take effect on the next module load. To apply immediately: unload and reload the module with modprobe -r then modprobe.
Blacklisting Modules
Blacklisting prevents a module from loading automatically. Useful for disabling a buggy driver, forcing a different driver, or preventing a conflicting module from loading alongside another.
# Blacklist a module
echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
# Blacklist and also prevent loading as a dependency
sudo tee /etc/modprobe.d/blacklist-nouveau.conf << 'EOF'
blacklist nouveau
install nouveau /bin/false
EOF
The install <module> /bin/false directive is stronger — it replaces the module's install command with /bin/false, preventing it from loading even as a dependency of another module.
# Verify a module is blacklisted
cat /etc/modprobe.d/*.conf | grep blacklist
💡 Shani OS ships several blacklists by default in/usr/lib/modprobe.d/:blacklist-firewire.confblocksfirewire-core/firewire-ohci/firewire-sbp2/firewire-net(no firewire hardware is expected, and it closes off a DMA attack vector),nobeep.confblacklistspcspkrto silence the PC speaker,noime.confblacklistsmei/mei_me(Intel vPro/AMT remote management), anddisable-unused-protocols.confdisables thedccp,sctp,rds, andtipcnetwork protocols viainstall <module> /bin/falseto shrink the network attack surface. Runcat /usr/lib/modprobe.d/*.confto see them; if you need to re-enable one on your own install, add the corresponding override in/etc/modprobe.d/(part of the persistent overlay described above).
Module Aliases
Aliases let you refer to a module by a friendly name or map a hardware ID to a driver.
# Show all aliases for a module
modinfo -F alias kvm_intel
# Show which module would handle a specific hardware ID
modprobe --show-depends pci:v00008086d00001234sv...
# List all alias mappings (from modules.alias in the kernel)
cat /lib/modules/$(uname -r)/modules.alias | grep iwlwifi
Dracut and the Initramfs
On Shani OS, the initramfs is built with dracut, but it is never built standalone — Shanios boots via signed Unified Kernel Images (UKIs), and regeneration happens through gen-efi during an OS deploy. Users do not rebuild the initramfs manually.
# Force-include a module in the initramfs
echo "add_drivers+=\" virtio_blk virtio_scsi \"" | sudo tee /etc/dracut.conf.d/virtio.conf
# Verify a module is present in the current UKI's initramfs
lsinitrd | grep virtio
⚠️ Do not run baredracut --forceon Shani OS: there is no plain/boot/initramfs-linux.imgto regenerate, only signed UKIs (shanios-blue.efi/shanios-green.efi). Initramfs/UKI regeneration happens viagen-efias part of an OS deploy (sudo shani-deploy), which rebuilds and re-signs both UKIs with yourdracut.conf.d/settings applied. After changing early-boot module configuration, deploy (or runsudo gen-efi configure <slot>for the active slot) and reboot to verify before removing the previous boot slot.
Firmware
Many modules require firmware blobs that are loaded from /lib/firmware/. Shani OS ships a comprehensive linux-firmware package split by vendor — firmware is baked into the OS image at build time, and kernel + firmware updates arrive via OS deploy (sudo shani-deploy), not via a package manager. If a module reports a missing firmware file:
# Check dmesg for firmware load failures
dmesg | grep -i firmware
dmesg | grep "Direct firmware load"
# List available firmware files for a driver
ls /lib/firmware/iwlwifi* # Intel Wi-Fi firmware
ls /lib/firmware/amdgpu/ # AMD GPU firmware
# Check which firmware package provides a file (read-only file-database query)
pacman -F /lib/firmware/iwlwifi-8265-36.ucode
If the firmware your device needs is genuinely absent from the image, you cannot add it to the read-only host yourself: request it upstream / file an issue against Shanios so it's included in the next image build. As an interim workaround, load the device from inside a Distrobox container or via Nix-packaged userspace tooling that bundles its own firmware handling.
Useful Diagnostics
# Show kernel messages related to module loading since boot
dmesg | grep -E "module|driver|firmware" | head -40
# Show all modules and their memory usage
lsmod | sort -k2 -rh
# Find which module handles a device (by PCI ID)
lspci -k | grep -A3 "VGA\|Network\|Audio"
# Find which module handles a USB device
lsusb -v 2>/dev/null | grep -E "idVendor|idProduct|Kernel driver"
# Check for module load errors at boot
journalctl -b | grep -i "module\|modprobe\|failed to load"
# Show all loaded modules with their sysfs paths
ls /sys/module/
Troubleshooting
| Issue | Solution |
|---|---|
modprobe: FATAL: Module not found | Module name may differ — check modinfo or search: find /lib/modules/$(uname -r) -name "name" |
| Module loads but device doesn't work | Check dmesg for firmware errors; verify firmware package is installed |
rmmod: ERROR: Module is in use | Check the "Used by" column in lsmod; unload dependent modules first, or use modprobe -r |
| Module loads but wrong driver is used | Blacklist the competing module in /etc/modprobe.d/ |
Changes to /etc/modprobe.d/ not taking effect | Unload and reload the module; or reboot; if it's an initramfs module, regenerate the UKIs via sudo gen-efi configure <slot> (or deploy a new OS version) |
| Missing firmware after OS update | Firmware ships inside the image — kernel + firmware arrive together via sudo shani-deploy; if your device's firmware is absent from the image, request it upstream / file an issue |
Module not loading at boot despite /etc/modules-load.d/ entry | Check systemctl status systemd-modules-load; verify the module name is correct with modinfo |
See Also
- Systemd —
systemd-modules-load.service, unit dependencies - Hardware —
lspci,lsusb, device identification - Storage — storage controller modules, NVMe
- Architecture: Dracut Initramfs Module — Shani OS initramfs build