A couple more solutions!
RFKILL
rfkill
was merged into the linux kernel in 2.6 and is a simple way to manage wireless devices.
For example, view wireless devices by calling rfkill
with no arguments:
cat@rt~ $ rfkill
ID TYPE DEVICE SOFT HARD
0 wlan phy0 unblocked unblocked
1 bluetooth hci0 blocked unblocked
Then (with sudo/root) block the devices rfkill block $TYPE
:
cat@rt~ $ sudo rfkill block bluetooth
cat@rt~ $ sudo rfkill block wlan
Now check their new status with rfkill
again:
cat@rt~ $ rfkill
ID TYPE DEVICE SOFT HARD
0 wlan phy0 blocked unblocked
1 bluetooth hci0 blocked unblocked
Note the devices I disabled are listed blocked
under SOFT
but not HARD
. This means we've disabled the device through software (and can re-enable the device through software).
A HARD
blocked device indicates the wireless device was hardware blocked. This could be a hardware kill switch (some laptops have a switch to toggle wireless off), or the device may be disabled by bios, or possibly doesn't have a driver for the software to interact with it (double-check me on that last one though).
modprobe
You may instead want to tell your kernel not to load the driver for these wireless devices at all. This means your OS and kernel won't know how to interface with these devices and they will remain unpowered.
First, check what kernel modules are currently loaded with lsmod
:
cat@rt~ $ sudo lsmod
Module Size Used by
btusb 57344 0
btrtl 20480 1 btusb
btbcm 16384 1 btusb
btintel 28672 1 btusb
bluetooth 577536 5 btrtl,btintel,btbcm,btusb
ecdh_generic 16384 1 bluetooth
ecc 32768 1 ecdh_generic
[...]
This is just what my machine has loaded. Yours may look different, or even be using different drivers.
We can see on my machine there's several bluetooth drivers running. btusb
, btrtl
, btbcm
, btintel
, and bluetooth
.
btusb
is the generic driver that each of the other modules relies on. It should be sufficient just to unload btusb
, but since I know the others aren't going to be used either, I like to be thorough and make sure none of these drivers load.
We will do this with modprobe
by telling its configuration file to ignore these kernel modules with the blacklist
command. This will go in /etc/modprobe.conf
[^1].
If this file doesn't exist for you, don't worry, you can simply create the file and edit it. If it exists already, just append these lines to the bottom.
cat@rt~ $ sudo vim /etc/modprobe.conf
# In the editor vim, I added these lines to the bottom of the file:
blacklist btusb
blacklist btrtl
blacklist btbcm
blacklist btintel
blacklist bluetooth
This won't take effect until your next reboot. At startup, modprobe
will use this file to know more about what kernel modules to load, and when it sees the blacklist
commands in this file, it will know to ignore modules with those names.
Footnotes
[^1]: You can define this either in /etc/modprobe.conf
, or if you prefer, you can use the directory /etc/modprobe.d/
and place a number of files within it ending in .conf
, all of which will be read and used.
systemctl disable bluetooth.service