Search This Blog

Thursday, July 28, 2016

Bumblebee on Ubuntu 16.04! Revised !

Bumblebee on Ubuntu 16.04! Revised !

Well life is not very easy, is it? I have been puling my hair out for the past 2-3 months when all of a sudden my bumblebee setup on Ubuntu 16.04 started to freak out. I have been monitoring my blog for comments and all my readers say they have had either a login loop or they have had black screens after following my instructions. Many have had weird issues with primus not connecting to bumblebee daemon.

So i have been searching the good old INTERNET while using nvidia-prime myself as an alternative and always asking my readers to not use driver other than nvidia-367. Well all was good for some time and then all of a sudden one day I started having the worst possible screen tearing with nvidia-prime and I was again disappointed with the state of primus support on Linux.

Have been trying various distributions to find out switching distros would really help. So I switched to all other possible distros. So what now?

I was very pissed wth all this and I had been talking to a friend of mine by the name Brett Stevens. We together cracked this puzzle.

So what exactly is the issue with this whole login loop (I thought switching to another Display Manager would help, Alas ! That changes nothing ) and black screen after bumblebee installation.

So how did I fix it?

“Here is how. By Installing Bumblebee and Nvidia-Prime both.” Now you would say that is crazy, How can that even work? Yeah Yeah ! I hear you. Please keep reading and you will have your answers.

So something changed with an update to Nvidia-36X.XX Series of drivers in Ubuntu 16.04 sometime after my earlier bumblebee post. Not sure what it was but here is the behaviour.

Something has been causing nvidia_drm, nvidia_modeset and nvidia-uvm to automatically load at boot. Nothing could prevent these bad boys to stop loading at boot. These automatically loading at boot is the reason why you have the login loop and black screen. So what to do . I tried manually blacklisting the modules but they would not stop. This was because nvidia drivers were enabling modesetting and automatically activating.

So we need something to prevent these modules from automatically loading. We now had a clear problem statement with no solution. So what to do. And then Brett Came across this article.

This changed the whole direction of investigation. I could not help noticing this step in his article.

sudo prime-select intel  

This was something I could not digest. However looking deeper we found that this was real. We were able to force the system to always use Intel using prime-select. The package nvidia-prime works a bit differently than bumblebee, It completely disables nvidia-card and forces intel card to be primary all the time. It can also force the system to use nvidia card as well.

Once Intel is forcefully made primary, There are no more login loops no more black screens. Now In addition to this we installed bumblebee as usual. No more errors, Switching is perfect. No issues.

So without further delay. Here are the simplified instructions.

To install and Configure Bumblebee on Ubuntu 16.04, Open up a Terminal and

Run the following Commands in Sequence

1) sudo apt-get update && sudo apt-get upgrade

2) sudo apt-get dist-upgrade

3) sudo apt-add-repository ppa:graphics-drivers/ppa (Skip this step if you are no t going to use Nvidia-364 or higher in future.)

4) sudo apt-get update && sudo apt-get dist-upgrade

5) sudo apt install nvidia-prime nvidia-367

6) sudo prime-select intel

7) sudo apt-get install bumblebee bumblebee-nvidia primus nvidia-settings nvidia-367 (You could use nvidia-364 or nvidia-367 if you have enabled Graphics Drivers PPA )

Once this is Installed, Below files need to be edited as shown.

1) sudo gedit /etc/modules



2) sudo gedit /etc/modprobe.d/bumblebee.conf

Check for this

# 361
blacklist nvidia-367
blacklist nvidia-367-updates
blacklist nvidia-experimental-361

Ensure that this section shown above exists. If not add it manually.

3) sudo gedit /etc/bumblebee/bumblebee.conf




(Or whatever version of Driver is latest if using Graphics Drivers PPA)

Also Change

Driver = nvidia on Line Number 22

7) sudo gpasswd -a $USER bumblebee

8) sudo systemctl enable bumblebeed

9) Reboot

10) Install mesa utils if not already installed

sudo apt-get install mesa-utils

Check using

11) primusrun glxinfo | grep OpenGL

You shoud see a result like this.

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 820M/PCIe/SSE2
OpenGL core profile version string: 4.5.0 NVIDIA 367.35
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5.0 NVIDIA 367.35
OpenGL shading language version string: 4.50 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:

This means all is well and  your bumblebee setup is working.

If you would like to see if bumblebee is actually working, try this

lsmod | grep bbswitch

You should see something similar to this

bbswitch 16384 0

The number in second column is Random and will vary.


if you run.

cat /proc/acpi/bbswitch

You should see something like this

0000:03:00.0 OFF

This means that your Nvidia Card is OFF by default. Once you run an application using primusrun or optirun commands, while the program you run is running you can see that the OFF change to ON Like below.

primusrun glxgears

this runs the glxgears program using your Nvidia Card via bumblebee.

Open another terminal and run.

cat /proc/acpi/bbswitch

You should see something like

0000:03:00.0 ON

Now Close the application which you launched via bumblebee earlier, in this Case glxgears.

again run

cat /proc/acpi/bbswitch

You should see something like this.

0000:03:00.0 OFF

If all is going like I have mentioned then you can be sure that bumblebee is configured correctly.

Thursday, July 14, 2016

KVM on Ubuntu Part I

How to Install KVM on Ubuntu 16.04?

I have been using Ubuntu a my primary Operating System for a long time now. Since my work involves working with new technologies all the time (mostly proprietary, like Microsoft Citrix Vmware AppSense etc..). I have to build virtual lab environments all the time. I could use Windows Server however that lasts me only for 180 days which is the standard evaluation period. I need to install and configure various products on top of Windows Server all the time. I tried all other options and over a period of time I have come to conclusion that there is nothing better than KVM for my purpose. It is free and Open Source and most importantly it performs really well.

Why use Ubuntu for KVM? As most of you out there who may have used KVM in the past would agree that KVM Is a very good virtualization platform, we all know that Red Hat is the main contributor to the code. Red Hat has moved away from the Xen Hypervisor to KVM. So Why not use something like a CentOS? Answer is simple KVM works equally well everywhere. I do all my Virtualization labs on my laptop which does not have too much RAM. Moreover I use Ubuntu on my laptop as a daily driver, so I decided to use KVM on Ubuntu. I chose Ubuntu because it is what I use day in and day out. It just works, I don't have to tweak it too much. You would be surprised to know that I actually like the default theme and colors! now you would say "YUCK", be my guest.

KVM itself is the whole setup which consists of QEMU the Hypervisor, Virt-Manager the console and libvirt, the subsystem which Virt-Manger uses to connect to QEMU. Libvirt can manage Xen and LXC as well. The goal of the post is not to get into the technical architecture/details, there is plenty of material online for that. I just want to provide a step by step walk through which will help you in getting up and running with KVM in no time.

After using it for some time now, I think it is time for me to share the secret sauce with you all and start a series of How to posts on my blog. Hence this blog post.

With that out of the way. Here are the steps to follow.

1. Install KVM by typing the following command in terminal.

 sudo apt install kvm virt-manager

Press y and then enter this downloads and installs the required packages. With Ubuntu all the dependencies are automatically selected and installed.

2. Reboot the system.

Technically there are other steps that are required like adding your user account to kvm and libvirt user groups. However Ubuntu automatically takes  care of that. All you need to do now is reboot and you should be fine.

3. Search for virt-manager in dash. Once rebooted hit the super/Window key to open dash. Type virt-manager and you should see something like this.

4. Launch Virt-Manager application. Below is how it looks like.

It lists the Hypervisors which it has connected to. This time around it shows QEMU/KVM. You could connect to multiple instances of KVM running on different servers using virt-manager application.

This way we have now installed KVM on Ubuntu and we are ready to configure basic settings so we could use it and spin up some Virtual Machines.
In my next how to, I will go through the Initial configuration and the best configuration that works for me and some general tips about getting the best out of this wonderful technology.