Software >> OS >> Unix >> Linux >> kernel >> How to prevent a kernel module from being loaded

 

BEFORE DISABLE


## check if fat kernel module is currently loaded, no output => not loaded

[root@rh6 ~]# lsmod | grep fat


## test if can enable

[root@rh6 ~]# modprobe fat


# confirm that it is loaded

[root@rh6 ~]# lsmod | grep fat
fat                    55184  0


 

 DISABLE


## remove the module if it was already loaded

[root@rh6 ~]#
modprobe -r fat


## confirm it is currently not loaded, i.e. lsmod output does not have that module

[root@rh6 ~]# lsmod | grep fat


## Disable it by telling modprobe to run /bin/true instead of actually inserting the fat module to the kernel when it tries to
## install that module

[root@rh6 ~]# echo "install fat /bin/true" > /etc/modprobe.d/fat.conf   ## the .conf filename can be anything you choose.

[root@rh6 ~]# cat /etc/modprobe.d/fat.conf
install fat /bin/true


## Try to insert the module to the kernel

[root@rh6 ~]# modprobe fat


## confirm it was not loaded, i.e. lsmod output does not have that module

[root@rh6 ~]# lsmod | grep fat