Appendix A. Preventing kernel modules from loading automatically You can prevent a kernel module from being loaded automatically, whether the module is loaded directly, loaded as a dependency from another module, or during the boot process. Procedure The module name must be added to a configuration file for the modprobe utility. This file must reside in the configuration directory /etc/modprobe.d . For more information on this configuration directory, see the man page modprobe.d . Ensure the module is not configured to get loaded in any of the following: /etc/modprobe.conf /etc/modprobe.d/* /etc/rc.modules /etc/sysconfig/modules/* # modprobe --showconfig <_configuration_file_name_> If the module appears in the output, ensure it is ignored and not loaded: # modprobe --ignore-install <_module_name_> Unload the module from the running system, if it is loaded: # modprobe -r <_module_name_> Prevent the module from being loaded directly by adding the blacklist line to a configuration file specific to the system - for example /etc/modprobe.d/local-dontload.conf : # echo "blacklist <_module_name_> >> /etc/modprobe.d/local-dontload.conf Note This step does not prevent a module from loading if it is a required or an optional dependency of another module. Prevent optional modules from being loading on demand: # echo "install <_module_name_>/bin/false" >> /etc/modprobe.d/local-dontload.conf Important If the excluded module is required for other hardware, excluding it might cause unexpected side effects. Make a backup copy of your initramfs : # cp /boot/initramfs-USD(uname -r).img /boot/initramfs-USD(uname -r).img.USD(date +%m-%d-%H%M%S).bak If the kernel module is part of the initramfs , rebuild your initial ramdisk image, omitting the module: # dracut --omit-drivers <_module_name_> -f Get the current kernel command line parameters: # grub2-editenv - list | grep kernelopts Append <_module_name_>.blacklist=1 rd.driver.blacklist=<_module_name_> to the generated output: # grub2-editenv - set kernelopts="<> <_module_name_>.blacklist=1 rd.driver.blacklist=<_module_name_>" For example: # grub2-editenv - set kernelopts="root=/dev/mapper/rhel_example-root ro crashkernel=auto resume=/dev/mapper/rhel_example-swap rd.lvm.lv=rhel_example/root rd.lvm.lv=rhel_example/swap <_module_name_>.blacklist=1 rd.driver.blacklist=<_module_name_>" Make a backup copy of the kdump initramfs : # cp /boot/initramfs-USD(uname -r)kdump.img /boot/initramfs-USD(uname -r)kdump.img.USD(date +%m-%d-%H%M%S).bak Append rd.driver.blacklist=<_module_name_> to the KDUMP_COMMANDLINE_APPEND setting in /etc/sysconfig/kdump to omit it from the kdump initramfs : # sed -i '/^KDUMP_COMMANDLINE_APPEND=/s/"USD/ rd.driver.blacklist=module_name"/' /etc/sysconfig/kdump Restart the kdump service to pick up the changes to the kdump initrd : # kdumpctl restart Rebuild the kdump initial ramdisk image: # mkdumprd -f /boot/initramfs-USD(uname -r)kdump.img Reboot the system. A.1. Removing a module temporarily You can remove a module temporarily. Procedure Run modprobe to remove any currently-loaded module: # modprobe -r <module name> If the module cannot be unloaded, a process or another module might still be using the module. If so, terminate the process and run the modpole command written above another time to unload the module.

Commands:
modprobe --showconfig <_configuration_file_name_>
modprobe --ignore-install <_module_name_>
modprobe -r <_module_name_>
echo "blacklist <_module_name_> >> /etc/modprobe.d/local-dontload.conf
echo "install <_module_name_>/bin/false" >> /etc/modprobe.d/local-dontload.conf
cp /boot/initramfs-USD(uname -r).img /boot/initramfs-USD(uname -r).img.USD(date +%m-%d-%H%M%S).bak
dracut --omit-drivers <_module_name_> -f
grub2-editenv - list | grep kernelopts
grub2-editenv - set kernelopts="<> <_module_name_>.blacklist=1 rd.driver.blacklist=<_module_name_>"
grub2-editenv - set kernelopts="root=/dev/mapper/rhel_example-root ro crashkernel=auto resume=/dev/mapper/rhel_example-swap rd.lvm.lv=rhel_example/root rd.lvm.lv=rhel_example/swap <_module_name_>.blacklist=1 rd.driver.blacklist=<_module_name_>"
cp /boot/initramfs-USD(uname -r)kdump.img /boot/initramfs-USD(uname -r)kdump.img.USD(date +%m-%d-%H%M%S).bak
sed -i '/^KDUMP_COMMANDLINE_APPEND=/s/"USD/ rd.driver.blacklist=module_name"/' /etc/sysconfig/kdump
kdumpctl restart
mkdumprd -f /boot/initramfs-USD(uname -r)kdump.img
modprobe -r <module name>