How to remove and disable BlueTooth support on Debian GNU / Linux servers

Thursday, 18th October 2012

How to remove / disable bluetooth support on Debian GNU / Linux servers
If you running Debian Squeeze Linux (as server Apache, MySQL, Qmail etc.) on brand new purchased hardware with bluetooth support; you will notice default Linux kernel will detect and load modules for Bluetooth

This would not be a problem only if Bluetooth does not pose possible errors or (even at cases even maybe system hangs ups?). The actual reason in my case to want to disable bluetooth on a productive Linux server operating like host was I found out in dmesg produced output, some errors related to Bluetooth, here they are:


root@deb:~# dmesg|grep -i 'call trace' -A 8
[323406.744439] Call Trace:
[323406.744440] [] ? lapic_next_event+0x18/0x1d
[323406.744450] [] ? __report_bad_irq+0x30/0x7d
[323406.744453] [] ? note_interrupt+0x105/0x16e
[323406.744455] [] ? handle_fasteoi_irq+0x93/0xb5
[323406.744458] [] ? handle_irq+0x17/0x1d
[323406.744460] [] ? do_IRQ+0x57/0xb6
[323406.744463] [] ? ret_from_intr+0x0/0x11
[323406.744464]

I saw this error and similar ones occuring, every now and then obviously displaying something wents wrongs with IRQs related to BlueTooth Communication with Kernel (as it keeps processing requests loaded in system memory) …

Well anyways having the bluetooth kernel module loaded on memory just takes up few chunks of useless assigned memory.
I don't have intention to use bluetoothever in future on these host so I decided to completely remove bluetooth support on those Debian.

1. Remove blueetoh support on Debian GNU / Linux

First to check info about the loaded kernel module bluetooth.ko and its assigned module load alias run:


root@deb:~# /sbin/modinfo bluetooth
filename: /lib/modules/2.6.32-5-amd64/kernel/net/bluetooth/bluetooth.ko
alias: net-pf-31
license: GPL
version: 2.15
description: Bluetooth Core ver 2.15
author: Marcel Holtmann
srcversion: 9FD5BF98FC88505DC637909
depends: rfkill
vermagic: 2.6.32-5-amd64 SMP mod_unload modversions

Secondly disable memory preloaded bluetooth.ko on the current host with cmds:


root@deb:~# rmmod -f bnep
root@deb:~# rmmod -f l2cap
root@deb:~# rmmod -f sco
root@deb:~# rmmod -f bluetooth

Default way to control if Bluetooth (on host support is ON or OFF) is through /etc/default/bluetooth. Inside /etc/default/bluetooth is a control variable:


BLUETOOTH_ENABLED=1

To shut it off change its value to 0:


BLUETOOTH_ENABLED=0

Then to permanently prevent bluetooth.ko from being ever in future loaded its also good idea to blacklist modules – bnep, btusb, bluetooth:


root@deb:~# echo 'blacklist bnep' >> /etc/modprobe.d/bluetooth.conf
root@deb:~# echo 'blacklist btusb' >> /etc/modprobe.d/bluetooth.conf
root@deb:~# echo 'blacklist bluetooth' >> /etc/modprobe.d/bluetooth.conf

Onwards re-build, current kernel initramfs:


root@deb:~# update-initramfs -u -k `uname -r` -v
......
......

Next update boot init scripts with update-rc.d to make sure bluetooth (service / daemon) is not started:


root@deb:~# update-rc.d bluetooth remove
......

That's all bluetooth will not load up anymore on next boot and at present time will not take up useless mem space.

2. Re-enable disabled blueetooth on Debian Linux
 
I've been asked in one of comments, what to do If you need to re-enable bluetooth on your Debian Linux at some time in future, so here are the steps to turn back blueetooth on again


/etc/modprobe.d/bluetooth.conf

Change variable:

BLUETOOTH_ENABLED=0

to 

BLUETOOTH_ENABLED=1

Open  /etc/modprobe.d/bluetooth.conf and remove any blacklisted modules, e.g:

'blacklist bnep'
'blacklist btusb'
&39;blacklist bluetooth'

Rebuild again kernel ramfs

root@deb:~# update-initramfs -u -k `uname -r` -v
 
Enjoy 🙂

Share this on:

Download PDFDownload PDF

Tags: , , , , , , , , , ,

4 Responses to “How to remove and disable BlueTooth support on Debian GNU / Linux servers”

  1. GC says:
    Google Chrome 35.0.1852.0 Google Chrome 35.0.1852.0 Mac OS X 10.10.0 Mac OS X 10.10.0
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1852.0 Safari/537.36

    Thanks for posting this article. Would you mind including the steps on how to re-enable Bluetooth in case in the future I would like to do that?

    View CommentView Comment
    • admin says:
      Google Chrome 40.0.2214.91 Google Chrome 40.0.2214.91 Windows 7 x64 Edition Windows 7 x64 Edition
      Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.91 Safari/537.36

      Hi GC,

      Thanks for note, steps included in article 🙂

      View CommentView Comment
  2. Hassiabiker says:
    Firefox 45.0 Firefox 45.0 GNU/Linux x64 GNU/Linux x64
    Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

    Hi,

    since this article is rather old, do you mind updating it?

    Eg. is this still valid for Debian jessie (8.7)?

    # update-rc.d bluetooth remove

    And also: disable bluetooth.service before unloading the kernel modules?
    # systemctl stop bluetooth.service

    View CommentView Comment
    • admin says:
      Firefox 53.0 Firefox 53.0 Windows 7 x64 Edition Windows 7 x64 Edition
      Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0

      Hi Hassiabiker,


      I guess the update-rc.d bluetooth remove should be working.
      If it is not working you can always do it manually with:
      /sbin/runlevel

      If it shows for example 5 it means you’re in runlevel 5 so to remove bluetooth just do:


      cd /etc/rc5.d; ls -al *bluetooth*; then rename any reference to bluetooth from S*something to K99-theNumber behind S capital letter
      for example if you have /etc/rc5.d/S20bluetooth to disable it do:
      mv /etc/rc5.d/S20bluetooth /etc/rc5.d/K79bluetooth
      and also to stop it for current boot do:
      /etc/init.d/bluetooth stop

      I don’t know what will be the situation with the bluetooth modules but you can check it with:

      lsmod|grep -i bluetooth
      or something and then just disable all modules that are loaded for bluetooth use and follow my instructions and add the respective bluetooth module to be disabled in /etc/modules just like I point in the article.

      On next booth it should not load any more.


      Hope this helps
      Regards,

      Georgi

      View CommentView Comment

Leave a Reply

CommentLuv badge