Linux

Disabling the built in bluetooth and use a USB adaptor instead (on Linux)

My laptop has an Intel wireless card for wifi, and an Intel Bluetooth adaptor too. Hardware wise I suspect there is just one hardware device, and this causes problems on Linux. Although I can scan for devices and pair with some of them, connections rarely work, and my Bluetooth headset does not connect and work most of the time. Apparently this is a known problem with the Intel driver.

I suspected the issue was entirely related to this combination device, so I bought a plug-in USB Bluetooth adaptor. This is where the next problem began. Although the underlying Bluetooth stack on Linux supports multiple controllers, none of the graphical configuration tools do. GNOME’s Bluetooth support, blueman, blueberry… they all are written to only work with one controller. Whatever I did, they only saw the Intel controller.

You can select the default Bluetooth controller via the bluetoothctl command line tool, but this still doesn’t affect the graphical tools. If you disable the Intel Bluetooth controller via the same tool – or via the graphical tools – then all of them insist Bluetooth is turned off whilst gleefully ignoring the second Bluetooth controller.

You also can’t just blacklist a kernel module, such as btintel because this seemingly disables the btusb module too, and the USB adaptor doesn’t work either. Trying to use rfkill won’t likely get you anywhere either.

There is however a solution! We can use good ‘ol udev rules to remove authorisation from a particular device. First of all we need to work out how to specify what USB device we want to disable. We need to find the vendor ID and the product ID. One method for this is lsusb -v. There is a lot of output from this, but you’ll want to find the built in device (in my case, Bus 001 Device 003: ID 8087:0a2b Intel Corp.). Underneath this it will have some information:

Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        64
  idVendor           0x8087 Intel Corp.
  idProduct          0x0a2b 

The lines we’re interested in are idVendor and idProduct. In my case the values I took from this output were 8087 for the vendor (Intel) and 0a2b (the product ID). As an aside, I love how Intel’s vendor ID is a reference to the Intel 8087 co-processor! (Apparently the Intel PCI ID is 8086 too!).

Another approach to find the information is to use udevadm, like so:

udevadm info -a -p /sys/class/bluetooth/hci0

This also outputs a lot of information. You want to find lines like:

    ATTRS{idProduct}=="0a2b"
    ATTRS{idVendor}=="8087"

If there are multiple entries you want to choose the entries near the top as the udevadm command walks up the device tree showing information for all parent devices (which we don’t want).

Once you know the product ID and the vendor ID we can now create a rules file and disable the device. Create a new rules file at /etc/udev/rules.d/81-bluetooth-hci.rules and add the following:

SUBSYSTEM=="usb", ATTRS{idVendor}=="your-vendor-id-here", ATTRS{idProduct}=="your-product-id-here", ATTR{authorized}="0"

Here is mine for example:

SUBSYSTEM=="usb", ATTRS{idVendor}=="8087", ATTRS{idProduct}=="0a2b", ATTR{authorized}="0"

Now all you need to do is reboot! Once you do the built in Bluetooth controller should vanish and all of the graphical tools should work nicely with your Bluetooth USB adaptor instead. ūüėÄ

Linux, Personal

Why I now prefer Arch Linux

Yesterday I installed Linux onto a fresh laptop and there was no debate in my mind what Linux distribution I would use – Arch. A year ago that would not have been the case, I might even have considered installing RHEL instead. So why Arch?

When I was younger – and still today – I noticed that most people I spoke to in the IT profession who had reached their fourth or fifth decade of life had given up on new ideas or new technologies and had settled into what they knew best. Although I respected this, I didn’t enjoy the thought that maybe one day I’d become the same way, even though I felt that my openness to new ideas and technologies was one of my strengths, and something I deeply enjoyed.

Well, I’m in my third decade of life now, and I have definitely begun to notice how easy it can be to settle down for what is comfortable and stick with it. Thankfully I haven’t lost my passion for new ideas and trying new things. Last year at Southampton we hired an intern, this in of itself is a tribute to my manager for changing the norm and doing something new because nobody had ever done that before. It was an eye opening experience, not just because it was enjoyable to teach, but because the internship taught us far more than we realised it would. It challenged us. It made us think differently. The whole team improved. What I didn’t expect was to change my preferred desktop operating system – but, it did. He (the intern) had an established like for Arch linux, advocated it when asked why, and left it at that. He didn’t push me to try it – but it made me want to try it. And so I did.

For a typical end user, Arch Linux is next to impossible to install. It doesn’t have an installer at all. The bootable image you download starts Linux running and then drops you at a zsh prompt. From there its entirely up to you on what you do next. The installation documentation is clear, concise, but not detailed – you need to know what you’re doing to get anywhere – but this, for me, is perfect. It gets out of the way, gives me the tools to install, and then lets me get on with it. I loved it.

The initial experience made me feel like a young teenager installing Linux for the first time. It literally made me feel young again. I felt like I was learning Linux again. Although I had used all these tools before, I had become used to an installer doing it all for me, and I enjoyed learning things I didn’t know about tools I’d used for years.

Arch Linux is minimalist, it is simple. It gets out of your way. You have total control over what your system looks like. It doesn’t hide details from you so you learn why things are done the way they are. At each stage the documentation lets you decide how you want to build your system and gives you information on why you might want to pick any particular solution.

It is easy to build a desktop linux installation. If you want GNOME, on Wayland, with all the bells and whistles, its easy. If you want Xorg and fluxbox, this is very easy too. If you want to use GRUB as your bootloader, you can, but if you want to use systemd-boot (as I do), you can do that too! Each option is easy to achieve, and isn’t hidden away. On Debian I wanted to switch to systemd-boot, but it was far more difficult than expected, and I gave up and just left it with GRUB. On Arch there is support for many different options, and they’re all very easy. You don’t have to accept what the distribution wants you to use.

The other fantastic feature of Arch Linux though is that it seems to solve the classic divide of Linux distributions: new software vs stable software. If I were to pick RHEL as my distribution it would be stable, sure, but the software is old, and most modern apps can’t be easily installed. Just getting flatpak on RHEL is next to impossible. I could alternatively pick Fedora, but then I have to go through a huge upgrade every six months and often things break.

Arch is a hybrid of these approaches, in that it is a¬†rolling release distribution. I have access to all the latest stable versions of all the software I want, but there is no ‘big bang’ forced upgrade every six months. I update when I want to, and Arch updates individual packages as they reach a stable point based on the application itself, rather than an arbitrary time deadline. With RHEL software is considered stable just because it is of a certain age – with Arch, software is considered stable when the developers have declared it to be so based on their thorough understanding of their own releases. You might think that Arch would be somewhat like Debian unstable – frequent bugs and breakages from updates – but in fact Arch seems to hit the sweet spot of stability¬†and modernity.

Pretty much my only criticism of Arch is the lack of a standard AUR installation tool in the base platform. AUR refers to ‘arch user repository’ – add-on software packages that aren’t maintained by the core team. It is heavily used by end users though, and there are many front end tools to make it easy to install AUR packages. Without one of these tools users have to clone a git repository and build packages themselves. With a frontend, such as pacaur (which is what I used), its as simple as using the standard package manager.

So, if you like Linux, and use it on the desktop, and want a better experience: go give Arch a try. You might just like it ūüôā

Linux

bargate 1.6

bargate, an open source web interface to SMB file servers,¬†hasn’t had many new features recently. It is now very stable/reliable and there is little need for any user-visible features. I do however plan a number of changes for v1.6:

Add pysmb support for better SMB2 performance

bargate uses the pysmbc library to talk to SMB file servers. This is a very thin wrapper around Samba’s libsmbclient – the defacto standard open source SMB client. Sadly when using SMB2 or later performance is terrible. The trouble seems to be in the stat() call, here is a comparison:

When using SMB2, pysmbc/libsmbclient performance is so bad that it is unusable. Until now this hasn’t really been a problem – everything supported SMB1 still, and Samba still doesn’t enable SMB2 by default. Since the Windows wannacry vulnerability though many folks are just turning SMB1 off altogether (although there really isn’t a good reason for doing so).

I haven’t made any progress with the Samba team in identifying why using SMB2+ is so much slower, so I’ve decided I will make the ‘backend’ of bargate modular. You will be able to choose which library to use – either pysmbc (libsmbclient) or pysmb, which is an alternative pure-python SMB1/2 implementation. Unlike pysmbc, the pysmb library does not suffer performance issues when using SMB2.

Switch to Bootstrap 4

When Bootstrap 4 is released I’ll switch over to using that rather than the current Bootstrap 3, and take the opportunity to re-write much of the HTML to make the pages more efficient.

Add text editing in browser

The final feature I’m planning to add in bargate 1.6 is support for editing files ‘in-browser’ via the codemirror javascript-based text editor. This would allow users to edit text documents from within bargate, such as plain text, or HTML or programming code.

Linux

Attacking racism does not stop racism

This year – 2016 – has to be one of the most politically divisive years in recent history. In the UK voters opted to leave the European Union, many clearly hoping to end immigration, and in the USA voters opted to elect Trump, again many hoping to end immigration. In both cases polls before the elections proved to be largely incorrect, and whats more, the principal of the silent majority seems to be the cause.

I’m not going to spend long arguing this point, but it seems clear to me that a lot of people in both countries didn’t admit how they truly felt and so also didn’t admit what they were going to vote for. After the election seemingly legitimatises how they voted they pretty much always say they hate being labelled racists and they feel like their fears and arguments are shut down as being racist. They usually end up by saying this vote means they are the majority and they are in fact not racist at all.

It is clear a majority of these voters feel ignored by the ‘establishment’ and feel that they are not represented. They are correct. The establishment has ignored them. Mainstream political parties don’t know what to do with them.

In both elections the winning slogans have been succinct and¬†obvious: “Take back control” and “Make America great again”. They are anti-progressive rallying calls and the left-wing and centre-ground response is to call people who agree with them ‘a basket of deplorable’s’, ‘racists’, ‘sexists’, ‘homophobes’ and ‘transphobes’. They are correct. These people really are motivated by these emotions.

It is thus both true that these people are ignored and¬†that they hold racist views. The mistake that we make is to demonise these people, to attack them and to call them racist – even if it is in fact true. Unless we’re planning on disenfranchising these people because they are racist then elections will continue to be lost and the “new right” will continue to grow – condemning them makes them more angry and more likely to vote for people like Trump who legitimatise actions which they think will make them feel better.

Recently I fell out with a close friend because his reaction to racism in America was to attack people who happened to be white¬†– calling them racists (“all white people are racist”). Rather than engage with these people, hold civilised debate, he called white people “saltine crackers”, he accused them of having no culture, and he accused them of not having friends who weren’t white. Such a reaction is obviously completely bonkers because it does nothing to actually end racism and discrimination. It only angers people further, and emboldens them to spread their unacceptable views. Its like fighting a house fire by throwing bombs at it.

What we need to do is accept that racism is natural and very human. Instead what happens more often than not is that we assume that racism exists only because white people are ‘inherently’ racist, which is in of itself racist! The irony should be obvious. We should seek to understand racism, accept that its a perfectly normal thing for people to feel, and educate ourselves on how to not take racist actions.

It is not hard to see why we’re all capable of having racist views. Humans evolved to survive – just like every other creature on earth. As such when we interact with people who look or act significantly different to ourselves we react in fear – because that is what kept us alive for the past few million years. Its a perfectly logical response. I will call upon Star Trek to better illustrate my point:

QUARK: You never pulled a stunt like that. You’re smart enough to know that people don’t want to be reminded that you’re different. Who wants to see somebody turn into goo? I hope you don’t do that around Kira.

ODO: Why shouldn’t I?

QUARK: If she’s anything like me, she’d rather you didn’t. Don’t you get it, Odo? We humanoids are a product of millions of years of evolution. Our ancestors learned the hard way that what you don’t know might kill you. They wouldn’t have survived if they hadn’t have jumped back when they encountered a snake coiled in the muck. And now millions of years later, that instinct is still there. It’s genetic. Our tolerance to other lifeforms doesn’t extend beyond the two arm, two leg variety. I hate to break this to you, but when you’re in your natural state, you’re more than our poor old genes can handle.

ODO: So what are you saying, Quark? That the Klingons couldn’t help what they did because of their genes?

QUARK: I’m not trying to excuse what they did. I’m only telling you why it happened.

from Star Trek: Deep Space Nine Season 7 Episode 14 “Chimera”

Now, some people might think Quark and I are justifying racism. What we’re doing is justifying racist feelings not actions.¬†Feeling fear and disliking people that are different from you is¬†normal. What matters is the actions you take based upon those feelings¬†and logical thought. We don’t teach this though. We simply condemn racism, and in the process, confuse and anger most human beings because we’re not making it clear that is is¬†perfectly normal and acceptable to feel fear and dislike about people who look or act differently.¬†What is NOT acceptable is intentionally acting on those feelings.

 

This is the difference between childhood and adulthood – learning to accept emotions and not just acting directly on them. What we need to do is encourage people to express how they feel and take positive action rather than voting for a narcissistic sexual predator who has no problem saying we should act on our fears¬†because…¬†“we have no choice”.

Personal

Don’t be so dramatic! Part 1

14667747

So Britain voted to leave the European Union. The leave campaign largely based its campaign on two pillars of “there won’t be an economic impact!” and “immigration must be controlled!”. Essentially the older and less educated people voted Leave after being lied to by the leave campaign. In order to provide evidence to leave voters who even now refuse to admit their mistake I will document on this blog every so often the reality of Brexit.

We’ve had enough of experts

  • On credit ratings:¬†The UK’s credit rating has been changed to ‘Negative’ by Moodys (one of the ‘big three’ credit agencies). “Moody’s said the referendum result would have “negative implications for the country’s medium-term growth outlook”, and it lowered the UK’s long term issuer and debt ratings to “negative” from “stable”.”¬†Source
    Standard and Poor‚Äôs has also warned Britain‚Äôs top ‚ÄúAAA‚ÄĚ credit rating is now at risk. Source
  • On the value of our currency:¬†“Sterling also plunged, falling more than 8% against the dollar and 6% against the euro.” Source
  • On the UK stock market:¬†FTSE100 down 3.12%. “In London the FTSE 250, which mostly comprises companies that trade in the UK, shed 7.2% to close at 16,088 points.” This was the worst slide in history. “That was the biggest daily slide for the index, and equated to ¬£25bn being wiped off the value of its¬†companies,¬†according to the LSE.”¬†Source, Source
  • On the topic of why the FTSE recovered:¬†“”A significant number of FTSE 100 stocks ended the day in positive territory, predominantly those companies with lots of overseas earnings, which stand to benefit from a weaker pound”¬†Source
  • On the lack of housing:¬†“House builders were also the three biggest fallers on the FTSE 100, with Taylor Wimpey suffering a 29% slide.”¬†Source
  • On British banks: “Major UK¬†banks were also badly hit. Lloyds fell 21%, while¬†Barclays and RBS both slid¬†18%.¬†HSBC, which¬†has a large Asian business, fell just¬†1.4%.”¬†Source
  • On the European stock market: “European markets have been well and truly spanked, however, with the Dax in Frankfurt down 6.8% – its worst day since the financial crisis in 2008, the Cac in Paris shed¬†8%, Madrid fell 12%, while¬†Milan takes the wooden spoon with¬†a¬†12.5% plunge.”¬†Source
  • On the US stock market:¬†“Wall Street wobbled further¬†in the last hour of trading in New York, with the¬†Dow Jones ending¬†more than 600 points, or 3.4%, lower¬†at 17,400 points – the biggest one-day fall in almost five years.¬†The S&P 500 fell¬†3.6% – the biggest daily slide in 10 months – while the Nasdaq slumped 4.1%. That was the tech-focused index’s¬†worst day since 2011.” Source
  • On the price of fuek: Prices are likely to rise: ‘Retailers and the AA motoring organisation warned that petrol prices were likely to rise by 2p-3p a litre because of the pound’s fall against the dollar.’ Source
  • On growth: “BBC business correspondent Joe Lynam tells a special edition of Business Live that¬†UBS is predicting UK economic growth will swiftly fall to¬†zero this year.¬†The Swiss¬†bank forecasts that GDP¬†will remain at zero¬†for much of 2017, raising the strong likelihood of a recession, he says.¬†It won’t take much – economic growth slowed to¬†0.4%¬†in the first quarter of the year.” Source
  • On jobs:¬†“Sources within Morgan Stanley have told the BBC that the bank is stepping up a process that¬†could see up to 2,000 of its London-based investment banking staff being relocated to Dublin or Frankfurt.”¬†¬†Source¬†Airbus, which employs thousands in the UK, said: “Britain will suffer” and “Of course we will review our UK investment strategy, like everybody else will.”¬†¬†Source

Its alright though, because: “Andrea Leadsom, a Leave MP, says¬†there “just is not the evidence”¬†of a financial meltdown hitting the UK in the wake of the vote, as predicted by some Remain campaigners.”

Lies, damn lies, and leave campaign lies

  • On spending money on the NHS instead of the EU: Farage admits that the idea of spending the ‘¬£350 million a week’ figure which we ‘send to the EU’ (which was proven to be a lie before the vote) will not be spent on the NHS. Source.
  • On immigration and the free movement of people: “Meanwhile, Conservative MEP and Leave campaigner Daniel Hannan told BBC Newsnight he could envisage a situation where the UK had “free movement of labour” and “From earlier on the Big Decision,¬†Conservative MEP and Leave campaigner¬†Dan Hannan¬†said¬†there was no promise to reduce immigration by leaving the European Union.”¬†Source
  • On France moving Calais border checks back to the UK: During the campaign it was suggested by France that they would no longer honour a 2003 deal in Calais. The leave campaign said this was ‘fear mongering’. Not surprisingly within 24 hours of the Brexit vote France said they would indeed end the deal.”The British must take the consequences of their choice,” she said on Friday.¬†Source
  • On stable government: David Cameron claimed he would stay on as Prime Minister even if he lost the referendum, and we were told by Leave campaigners that he should stay on whatever the outcome. The reality: he resigned. Source
  • On the ‘United’ Kingdom:¬†The leave campaign assured us that there would be no second Scottish independence referendum. After Scotland voted to remain overwhelmingly the Scottish government has begun work to hold one. Source
  • On trade deals with the rest of the world:¬†“A White House spokesman said Mr Obama “stands by what he said” about the UK going to “the back of the queue” when it comes to trade deals with the US.” Source

This of course was just the first 24 hours. Uncertainty is the order of the day.