Disable bluetooth at boot
I’m trying to disable the bluetooth at boot, without blacklisting the kernel module.
I commented the following two lines in the /etc/init/bluetooth.conf
:
start on started dbus
stop on stopping dbus
Then I added:
stop on runlevel [0123456]
In the file /etc/init.d/bluetooth
, wright before the exit 0
, I added the line:
rfkill block bluetooth
None of those try succeeded.
I saw on the Internet to add the last command in the /etc/rc.local
file. But instead of this file, I’ve got rc0.d
to rc6.d
and rcS.d
folders, full of symbolic links to scripts.
I’m running under Ubuntu-Mate 17.04, with the 4.10.0 kernel.
Just in case someone else needs the answer 😉
If the user is running systemd (default in many distros) the service can be disabled with
systemctl disable bluetooth.service
to deactivate bluetooth on startup issue this
sudo systemctl disable bluetooth.service
then on next reboot bluetooth will not be active … to view status issue
sudo systemctl status bluetooth.service
to activate bluetooth on startup issue this
sudo systemctl enable bluetooth.service
The accepted solution completely disables bluetooth till the service is (re)started.
In case you want to disable BT temporarily until you need it, your problem is probably that the bluez or the blueman-applet enables bluetooth at startup and/or login, respectively.
The former can be disabled by setting AutoEnable=false
in the [Policy]
section of /etc/bluetooth/main.conf
.
On Debian(-based) distributions it is most likely set to true and can be disabled via:
sudo sed -i -e 's/^AutoEnable=true/AutoEnable=false/' /etc/bluetooth/main.conf
The latter can be disabled in the GUI’s plugin settings unter "PowerManager" or via the following (from https://askubuntu.com/a/923539/244648):
gsettings set org.blueman.plugins.powermanager auto-power-on false
(This answer was incomplete for two years because the bluez bit was missing. Thanks to Dohd for bringing that up.)
Edit the bluetooth configuration file and set AutoEnable to false to disable bluetooth on boot.
sudo gedit /etc/bluetooth/main.conf
At the end of the file
AutoEnable=false
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.
- modprobe config file man page
- modprobe man page
- a (slightly dry) explanation of kenel module loading
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.
I use TLP;
you can edit the configuration file in order to disable bluetooth at boot, by adding this line:
DEVICES_TO_DISABLE_ON_STARTUP="bluetooth"
If TLP UI is installed too, remember to carry out the changes here, as they might not otherwise take effect and be syncronized with the user interface.
On debian/kali please check following:
in /etc/default/bluetooth BLUETOOTH_ENABLED=0
in /etc/bluetooth/main.conf AutoEnable=false
and if you have blueman-applet, check it’s plugin PowerManager settings