# Blacklist kernel module ?



## JBlake (Jun 9, 2016)

Hello,

I've some troubles with Bluetooth module _ng_ubt_ on FreeBSD 10.3 .
It is automatically loaded at boot, despite _ng_ubt_load="NO"_ put in /boot/loader.conf. Even if I manually unload with _kldunload ng_ubt_ it reloads itself back(?!), as shown by kldstat.

This module turns on bluetooth device which is an unwanted behavior, as it consumes additional power causing faster battery depletion and it may also be the cause of issues with resuming from suspend.

Is there some way how tell kernel to *not load* this module, ie. some blacklist of modules with quirks and prevent their loading ?


----------



## usdmatt (Jun 9, 2016)

Modules generally aren't loaded on boot unless you specifically enable them in /boot/loader.conf, so I wouldn't expect `{some_module}_load="NO"` to do anything.

I suspect one of the devfs rules is loading it. There are quite a few rules in /etc/devd/usb.conf that appear to load the ng_ubt module when they detect a bluetooth device. I don't know if a module can be forced to stop loading but you could try and comment out the devfs rule that is loading it (if it is devfs).


----------



## tobik@ (Jun 9, 2016)

usdmatt said:


> Modules generally aren't loaded on boot unless you specifically enable them in /boot/loader.conf, so I wouldn't expect `{some_module}_load="NO"` to do anything.
> 
> I suspect one of the devfs rules is loading it. There are quite a few rules in /etc/devd/usb.conf that appear to load the ng_ubt module when they detect a bluetooth device. I don't know if a module can be forced to stop loading but you could try and comment out the devfs rule that is loading it (if it is devfs).


To find your device in there you might need its vendor and product ids which can be obtained with `usbconfig dump_device_desc`.

You could also "blacklist" by `mv /boot/kernel/ng_ubt.ko /boot/kernel/ng_ubt.ko.blacklisted` .


----------



## kpa (Jun 9, 2016)

I think the best way is to use device hints in loader.conf(5) to disable the device even if the module gets loaded. This should do it:


```
hint.ng_ubt.0.disabled="1"
```

If there are more than one of the same device you need do the same with the unit number set to 1, 2 and so on.


----------



## victron (May 21, 2017)

too late.... just for indexing into google ))
it could be done like below, major point in priority value


```
cat /usr/local/etc/devd/black_list_bluetooth.conf
# try to don't load bluetooth module
# bluetooth on lenovo T410
nomatch 50 {
        match "bus" "uhub[0-9]+";
        match "mode" "host";
        match "vendor" "0x0a5c";
        match "product" "0x217f";
        #action "kldload -n ng_ubt";
        action "logger blocked bluetooth module";
};
```


----------



## ldgc (Mar 1, 2018)

I have the same issue that the OP mentioned, except that in my case is on FreeBSD 11.1.
Is victron's answer a reliable solution?


----------



## ldgc (Aug 1, 2018)

Today I tried victron suggestion in 11.2-RELEASE and it worked 
However /boot/kernel/if_run.ko doesn't automatically load when USB wireless adapter is attached liked it used to.
Is this behavior expected?
Thanks in advance


----------



## Deepak Ukey (Jul 19, 2019)

I am facing same kind of issue. I have storage driver which is inbox, i want to blacklist the driver and load the same module with some modification in source. Can anyone please help me on this.
Thanks in advance !!


----------



## SirDice (Jul 19, 2019)

Deepak Ukey said:


> I have storage driver which is inbox,


Sorry? It's probably a language/translation issue. What driver are you talking about?


----------



## Deepak Ukey (Jul 22, 2019)

SirDice said:


> Sorry? It's probably a language/translation issue. What driver are you talking about?


I am talking about smartpqi driver and i am using FreeBSD 12.0.


----------



## SirDice (Jul 22, 2019)

The smartpqi(4) driver is loaded by default in GENERIC. What exactly do you want to change? The easiest way is to build a custom kernel with this driver excluded. Then you can kldload(8)/kldunload(8) it.


----------

