For those people who have made the switch to a laptop as their primary system, Linux has presented a bit of a problem. Some integrated devices have less than stellar support and even the proprietary binary graphics drivers have left something to be desired. Worse, modern laptops that contain the ‘Optimus’ technology (multiple GPU configurations – NVidia and Intel) either had to be used in one mode or the other (one or the other X Server, but not both). Enter the ‘bumblebee’ project. This project allows you to compile support onto your system to allow you to designate certain applications to use the discrete driver (NVidia) for better video/game performance but did not address the ability to use both video cards for desktop display of multiple monitors. Today, we will address that shortcoming.
Your Mileage May Vary
This process has been tested on both a Dell and Lenovo desktop, one running Optimus on an NVidia 610m and one on an NVS4200m, both using an Intel 3000 chipset. This is exclusively oriented to Ubuntu Linux 12.04/12.10 (looks like it works on 13.04 as well) but has not been tested on Fedora/CentOS/RedHat/Suse. I am confident it would work on Mint and Debian as well, but YMMV…
A Little Planning
So, I am assuming that you want to use your system with TWO external monitors AND your laptop display for a triple monitor setup. The order of the screens will be important as you create your script to finalize the desktop appearance, but the instructions and explanations of what you need are easily adaptable regardless of your needs or configuration. Once you have your layout physically set up, there are a couple of things you will want to do up front so you can save yourself time and headaches later.
First off, backup your existing X configuration:
sudo cp /etc/X11/xorg.conf /home/username/xorg.conf.backup
This way, if we end up with a completely borked configuration, we can easily revert by booting into safe mode and copying the original file back in place and then start over. Next we need to make sure our distribution ‘sees’ both the NVidia and Intel video devices (sometimes it has to be enabled in BIOS before this will happen). We can check by executing:
sudo lspci | grep VGA
and you should see something like:
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [Quadro NVS 4200M] (rev a1)
At this point, if you have installed the proprietary NVidia drivers (which I had), we need to clean those off and purge all traces as well as remove traces of the Nouveau open source implementation of them. We will execute the following, in order:
sudo ./NVIDIA-Linux-x86_64-295.49.run --uninstall
sudo apt-get remove --purge nvidia-current nvidia-settings
sudo apt-get --purge remove xserver-xorg-video-nouveau
You can reboot here and you will end up in a text console OR in a generic (and ugly) generic VGA console in XWindows after.
Buzzing the System
Now we will download and install the latest drivers and bumblebee directly. Let’s add the repository:
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo add-apt-repository ppa:bumblee/stable
Let’s update our system:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nvidia-current nvidia-settings
Latest version of bumblebee and the NVidia plugin:
sudo apt-get install bumblee bumblebee-nvidia
and a final step to make sure everything has the right permissions to run (adds our user to the bumblee group):
usermod -a -G bumblebee $USER
Now here is where the rubber meets the road in the bumblee process. If you get through this, the rest is just a matter of arranging your displays after identifying the interfaces they are plugged into. We are going to have to patch the X Server to create an extra virtual screen, which we will later ‘copy’ to the third display in our configuration. Open a command prompt and execute the following:
sudo apt-get build-dep xserver-xorg-video-intel
sudo apt-get source xserver-xorg-video-intel
Grab the latest patch to apply:
sudo patch -p1 < xserver-xorg-video-intel-2.XX.X_virtual_crtc.patch
and we have to build and then install our driver:
sudo dpkg-buildpackage -b
cd .. & sudo dpkg --install xserver-xorg-video-intel-*.deb
FINALLY, we have to download and install the screen clone source that we need later:
git clone git://github.com/liskin/hybrid-screenclone.git
cd hybrid-screenclone && make && cp screenclone /usr/bin
Whew… Couple of final steps to make sure we are good to go. Configuration is pretty simple, we just need the following lines as follows:
Just in case, I have uploaded my full bumblebee.conf for reference. Additionally, since configuring ‘xorg’ is and always has been a royal pain, I have included my /etc/bumblebee/xorg.conf.nvidia for reference. We can then test our configuration as follows:
startx --config /etc/X11/xorg.conf.test
If there are any errors at this point, we will see them printed out to the console using the typical XWindows error mode.
Triple Monitor Beauty
We are almost there. Restart the system and login. You should now be in a ‘normal’ XWindows session with one external display ON, the laptop display ON and your third monitor blank. We need to turn on ‘optirun’ which is the utility that allows you to specify commands to use the discrete NVidia graphics chip, user ‘xrandr’ to setup the layout of our monitors using the connection values on our graphics cards and finally, copy the ‘cloned’ screen to our third display. I wrote a script that is executed AFTER I log in to my X session to do this:
xrandr –output LVDS1 –mode 1920×1080 –output VGA1 –mode 1920×1080 –right-of LVDS1 –output VIRTUAL –mode 1920×1080 –left-of LVDS1
screenclone -d :8 -x 2
I placed the ‘sleep’ command before each of the major sections so each previous command has time to complete before the next is run. In my case, xrandr configures the three outputs (LVDS1, VGA1 and VIRTUAL) laid out with the laptop screen in the center, my normal connected display to my right and the virtual display to the left. Lastly, the ‘screenclone’ command takes that virtual display and copies it to the correct display. Once this is done, I have all three screens running in Linux using BOTH the Intel and NVidia chips!
This script has to be run after every reboot and any time you want all three monitors to be used. I left it as a script because it is easy for me to NOT run the configuration when I just want to use my laptop alone or in dual monitor mode. You can still use the NVidia chip this way by executing an ‘optirun command’ and the output will use the discrete graphics card for processing. Although we are not at the point that Optimus technology is in Windows, at the very least, we now have a viable solution that prevents us from using our systems to their full potential. If anyone has any issues or questions, feel free to ask in the comments below and I will do my best to address them.