16

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.

1
  • 1
    Have you tried using systemd? e.g. systemctl disable bluetooth.service Aug 21, 2017 at 23:54

7 Answers 7

17

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

1
  • Upon deactivating and rebooting I fail to be able to enable bluetooth through the Gnome menu.
    – Johan
    May 22 at 10:59
10

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.)

4
  • Doesn't work on Ubuntu 20.04. Says No such schema “org.blueman.plugins.powermanager”
    – Ali Tou
    Sep 18, 2020 at 9:01
  • if gsettings list-schemas | grep blue does not show any results this answer does not apply to your environment at all. It's also possible that they have changed the path/name. In that case the output above might help figure that out or you can use the GUI path I described as well.
    – stefanct
    Sep 19, 2020 at 10:12
  • Disabling blueman/bluetooth applet Auto power-on will prevent it to enable bluetooth radio if it was previously disabled when the applet is starting (usually when logging in). Mine was already enabled just after booting, so I used tlp to manage bluetooth state (enabled or not) when computer is booting and voilà! See /etc/tlp.conf if it is installed on your computer.
    – Totor
    Nov 30, 2020 at 17:48
  • The better option seems to be to not enable it in the first place ;) See Dohd's answer or my edit unix.stackexchange.com/a/598994/41065
    – stefanct
    Aug 27 at 14:22
8

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
5

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

2
  • this should work on all distributions. Even "systemd" free ones Jan 24 at 12:39
  • did not working having tlp installed
    – Johan
    May 22 at 12:02
3

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.

3
  • What makes a wireless card completely powered off (or disabled to the deepest level), hard block or blacklist? Will soft block still have the wireless card powered on and doing electrosmog?
    – baptx
    Jun 29 at 15:38
  • 1
    @baptx Both rfkill and blacklisting the module will prevent the card from powering on. Notably, rfkill soft block also prevents power; hard simply means there's a physical switch interrupting the circuit. Look at the introduction of the rfkill man page: kernel.org/doc/Documentation/rfkill.txt
    – catleeball
    Jun 30 at 18:57
  • do you have to rebuild the initram after making this change? I'm trying to disable bluetooth at boot too, and I think the modules are already loaded at that initial bootstrap.
    – RJVB
    Oct 24 at 11:41
2

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.

2
  • Thanks for reminding! I using thinkpad and forgot on tlp they has this ability. ah! Oct 15, 2022 at 8:01
  • only working solution on my end.
    – Johan
    May 22 at 12:03
1

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

3
  • Do note that the OP specific Ubuntu as their OS. I'd also point out that /etc/bluetooth/main.conf has already been covered
    – Jeff Schaller
    Nov 6, 2020 at 19:53
  • Please explain; what is the difference between the two settings?
    – Johan
    May 22 at 11:28
  • The "BLUETOOTH_ENABLED" is specific to the Bluetooth service. When set to "0," it disables the Bluetooth service on the system. The second setting "AutoEnable" is related to the Bluetooth daemon's behavior. By setting it to "false," the Bluetooth daemon will not automatically enable Bluetooth devices upon startup. This means that devices will need to be manually enabled by the user or through specific commands. In summary, "BLUETOOTH_ENABLED=0" disables the Bluetooth service itself, while "AutoEnable=false" controls the automatic enabling of Bluetooth devices by the Bluetooth daemon.
    – partinis
    May 23 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .