Cannot change bluetooth device name

Bug #989817 reported by Junjie Jin on 2012-04-27
This bug affects 33 people
Affects Status Importance Assigned to Milestone
bluez (Ubuntu)
Mathieu Trudel-Lapierre
ubiquity (Ubuntu)

Bug Description

First, the bluetooth device name is incorrect by default. It should be like "computer name + device number". In Ubuntu 11.10, if the computer name is "mypc", the BT device name will be "mypc0". However, in 12.04, it's always "ubuntu0".

Second, the trick using hciconfig hci0 name "new_name" won't work for 12.04 while it did work for 11.10. The name will restore to "ubuntu0" after reboot or restarting bluetooth service.

Third, /etc/bluetooth/main.conf doesn't work. If I set the value for "name" field in the config file, it won't affect the device name.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: gnome-control-center 1:3.4.1-0ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-24.37-generic-pae 3.2.14
Uname: Linux 3.2.0-24-generic-pae i686
NonfreeKernelModules: nvidia
ApportVersion: 2.0.1-0ubuntu6
Architecture: i386
Date: Fri Apr 27 23:09:10 2012
EcryptfsInUse: Yes
ExecutablePath: /usr/bin/gnome-control-center
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release i386 (20120423)
 PATH=(custom, no user)
SourcePackage: gnome-control-center
UpgradeStatus: No upgrade log present (probably fresh install)
 activity-log-manager-control-center 0.9.4-0ubuntu3
 deja-dup 22.0-0ubuntu2
 gnome-bluetooth 3.2.2-0ubuntu5
 indicator-datetime 0.3.94-0ubuntu2

Junjie Jin (chen5317) wrote :
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bluez (Ubuntu):
status: New → Confirmed
Changed in bluez (Ubuntu):
importance: Undecided → Low
assignee: nobody → Mathieu Trudel-Lapierre (mathieu-tl)

For the issue with /etc/bluetooth/main.conf; please see bug 837196.

I'm curious, is the file /etc/hostname properly containing "mypc" rather than "ubuntu"?

I just can't begin to comprehend where this name would come from otherwise.

Changed in bluez (Ubuntu):
status: Confirmed → Incomplete
Junjie Jin (chen5317) wrote :

You may consider "mypc" as the name I gave to my system. I've changed the hostname during the installation, so in /etc/hostname, it's "mypc" now. I don't know what's the default hostname since I've already changed it. The problem is, it seems bluetooth setting in Ubuntu 12.04 somehow ignores this hostname. However, in Ubuntu 11.10, if I name my system as "awesome_name", bluetooth name will become "awesome_name0".

Junjie Jin (chen5317) wrote :

Well, I tried the PRETTY_HOSTNAME in /etc/machine-info. It works now. Seems bluetooth will read that file or something? I don't really understand how these things work. Most importantly, for now, it solved the problem. But I still hope there is some formal way to change the name.

Carroarmato0 (carroarmato0) wrote :

I believe I may have found something.

After searching through the whole filesystem I came across this directory: /var/lib/bluetooth

This containes folders to watch appears to be related to my bluetooth module, specifically, this file caught my attention: /var/lib/bluetooth/00:22:69:C3:AD:BE/config

name ubuntu-0
pairable yes
class 0x7e0100

I haven't tried changing that, but I think this might be "the droids we are looking for"

Carroarmato0 (carroarmato0) wrote :

Good news everyone, after changing that value to the hostname I wanted it persisted after a reboot :)

Changed in bluez (Ubuntu):
status: Incomplete → New
Changed in bluez (Ubuntu Precise):
importance: Undecided → Low
Rudi Daemen (fludizz) wrote :

I can confirm Carroarmato0 his solution indeed works :) I was able to change the hostname as well using the file /var/lib/bluetooth/[MACaddress]/config

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bluez (Ubuntu Precise):
status: New → Confirmed
Changed in bluez (Ubuntu):
status: New → Confirmed
Carroarmato0 (carroarmato0) wrote :

I've noticed than when sending a file from my laptop to my android phone through bluetooth, my phone sees my laptop as the hostname I configured.

But when I take a look at the info about the file I just transfered, it's says ubuntu-0. Not sure if it's something on my phone because of a previous pairing, or, somewhere "ubuntu-0" is still being used.

TJ (tj) wrote :

To permanently change the adapter device name using a bluez tool we have to use DBus to set the name using org.bluez.Adaptor.SetProperty which is handled by set_name(), which results in a call to adapter_set_name() which in turn calls write_local_name().

dbus-send --print-reply --system --dest=org.bluez /org/bluez/$(pidof bluetoothd)/hci0 org.bluez.Adapter.SetProperty string:'Name' variant:string:'adapter_name'

$ dbus-send --print-reply --system --dest=org.bluez /org/bluez/$(pidof bluetoothd)/hci0 org.bluez.Adapter.SetProperty string:'Name' variant:string:'adapter_name'
method return sender=:1.164 -> dest=:1.189 reply_serial=2

$ cat /var/lib/bluetooth/00\:1F\:E1\:E0\:EB\:96/config
name adapter_name
pairable yes
class 0x6e0100
onmode discoverable
mode discoverable

'bluetoothd' reads "/etc/bluetooth/main.conf" where we have "Name = %h-%d" which should be expanded to "<host>-<adapter_id>".

This is passed to the 'adaptername' plugin function adaptername_probe() which calls read_pretty_host_name(). This function looks for a systemd-specific text file "/etc/machine-info" and if found reads the file then looks for a line with the prefix "PRETTY_HOSTNAME=" and uses the name assigned there.

If no name has been set at this point read_local_name() is called to get the name from "/var/lib/bluetooth/$MAC/config". If no name is obtained from that file expand_name(,,"%h-%d",) is called and a name created from the machine hostname and bluetooth adapter id, e.g. "hostname-0".

This is later written out to "/var/lib/bluetooth/$MAC/config".

It appears to me that "ubuntu-0" is created during installation from a liveISO environment where the default machine name is always "ubuntu". Bluetooth starts in the live environment and assigns the "ubuntu-0" name to the adapter. Later, when bluetoothd is installed in the target the configuration file is probably copied over, or otherwise generated based on the live environment.

Once there is a name entry in "/var/lib/bluetooth/$MAC/config" the bluetoothd adaptername plugin will not generate a new name.

---- debug with "name adapter_name" setting in /var/lib/bluetooth/$MAC/config ----
bluetoothd[11119]: src/main.c:parse_config() name=%h-%d
bluetoothd[11119]: src/plugin.c:add_plugin() Loading adaptername plugin
bluetoothd[11119]: plugins/hciops.c:read_local_name_complete() hci0 status 0
bluetoothd[11119]: plugins/hciops.c:read_local_name_complete() Got name for hci0
bluetoothd[11119]: plugins/adaptername.c:adaptername_probe() Setting name 'adapter_name' for device 'hci0'
bluetoothd[11119]: plugins/hciops.c:hciops_set_name() hci0, name adapter_name

-- debug with no "name" setting in /var/lib/bluetooth/$MAC/config ----
bluetoothd[11425]: src/main.c:parse_config() name=%h-%d
bluetoothd[11425]: src/plugin.c:add_plugin() Loading adaptername plugin
bluetoothd[11425]: plugins/hciops.c:read_local_name_complete() hci0 status 0
bluetoothd[11425]: plugins/hciops.c:read_local_name_complete() Got name for hci0
bluetoothd[11425]: plugins/adaptername.c:adaptername_probe() Setting name 'XPSm1530-0' for device 'hci0'
bluetoothd[11425]: plugins/hciops.c:hciops_set_name() hci0, name XPSm1530-0

TJ (tj) on 2012-09-24
Changed in ubiquity (Ubuntu):
status: New → Confirmed
TJ (tj) wrote :

Ubiquity bug #644198 "Ubuntu LIve Cd does not enable bluetooth before choice menu in live-cd" comment #16 introduced the naming issue by coping the live environment from "/var/lib/bluetooth/" to "/target/var/lib/bluetooth/". The pertinent parts of the change are:

ubiquity (2.9.27) precise; urgency=low

  * Add bin/ubiquity-bluetooth-agent, a bluetooth agent allowing any HID
    bluetooth device for 5 minutes, then spawning bluetooth-applet if
    available, otherwise simply dies.
  * Start bluetooth-applet from ubiquity-dm (LP: #644198)
  * Copy /var/lib/bluetooth to /target/var/lib/bluetooth to keep the list
    of trusted devices on the target system. (LP: #644198)

 -- Stephane Graber <email address hidden> Fri, 09 Mar 2012 12:11:19 -0500

I'm emailing Stephane about this issue.

Changed in ubiquity (Ubuntu Precise):
status: New → Confirmed
Steve White (stevan-white) wrote :

This is an important bug, Mathieu.

All my bluetooth Ubuntu computers are named "Ubuntu-0".
Couldn't we have them all named "Bruce" to avoid confusion?

Hristo Erinin (zorlem) wrote :

This bug is still present in Saucy Salamander (13.10) and affects Trusty Tahr (14.04) after upgrading from a previous release.

In addition to that in 14.04 there is no way to override the name specified in /var/lib/bluetooth/$ADDR/config through the GUI tools so I have created

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers