NOTE: This project is no longer maintained. These instructions are available here for archival purposes.

Optimal Ubuntu Graphics Setup for Thinkpads

Motivation

This setup, combined with thinkdisp will get you:
1) Multiple Monitors
2) Working 3D Acceleration on all displays (so compiz effects work)
3) Power saving when mobile (Nvidia card off)
4) Safe updating without killing the multimon setup
5) The ability to use VT-x (which has to be disabled in BIOS in discrete-only mode due to a bug)

If you’d like to learn more about how the graphics are wired and why these workarounds are necessary, check out Zachary Sunberg’s post here. None of this would have been possible without his original guide, which can be found in the sources at the end of this page. Additionally, if you’re running Arch Linux, check out Gordin’s adaptation of this guide for Arch.

For guaranteed success, you should follow these instructions to the letter. I’ve been able to successfully perform them multiple times on a clean install of 12.04 x64 on my W520.

Instructions

First, go ahead and install Bumblebee. This gives you the ability to switch the nvidia card on/off in Optimus Mode (make sure this is set in BIOS).

sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia
view raw thinkubuntu-1 hosted with ❤ by GitHub

Once that’s done, reboot. Next, you’ll install some dependencies for later parts.

sudo apt-get install xorg-dev
sudo apt-get install git
view raw thinkubuntu-2 hosted with ❤ by GitHub

Now, patch and install the Intel Graphics Driver to allow it to support a virtual display. (Thanks to liskin for the patch)

sudo apt-get build-dep xserver-xorg-video-intel
sudo apt-get source xserver-xorg-video-intel
cd xserver-xorg... #(the source you just downloaded, tab to autocomplete)
wget https://raw.github.com/liskin/patches/master/hacks/xserver-xorg-video-intel-2.18.0_virtual_crtc.patch
patch -p1 < xserver-xorg-video-intel-2.18.0_virtual_crtc.patch
sudo dpkg-buildpackage -b
cd ..
sudo dpkg --install xserver-xorg-video-intel_2.17.0-1ubuntu4_amd64.deb #(again, tab to autocomplete will let you avoid typing this long name)
view raw thinkubuntu-3 hosted with ❤ by GitHub

Reboot again. At this point, if you execute xrandr in terminal, you should see two displays listed, one of them will be named VIRTUAL. This indicates that everything has installed correctly up to this point. Next, you’ll need to install screenclone, which copies the VIRTUAL display to your external display. (Thanks again to liskin, the developer of screenclone).

git clone git://github.com/liskin/hybrid-screenclone.git
cd hybrid-screenclone
sudo make
sudo cp screenclone /usr/bin/
sudo chmod +x /usr/bin/screenclone
sudo cp xorg.conf.nvidia /etc/bumblebee/xorg.conf.nvidia
sudo rm /etc/X11/xorg.conf
view raw thinkubuntu-4 hosted with ❤ by GitHub

Now, as explained here, you’ll need to make the following modifications to /etc/bumblebee/bumblebee.conf:

Driver=nvidia
KeepUnusedXServer=true
PMMethod=none
view raw thinkubuntu-5 hosted with ❤ by GitHub
You can see a copy of my bumblebee.conf for reference here. If everything seems to have installed without error, reboot one last time. Now connect your VGA or Displayport monitor and do the following: (thanks to RCSIRIUS in the comments below for confirming Displayport functionality)

optirun true
##(this starts the xserver and the settings you've modded above will prevent bumblebee from shutting it off)
xrandr --output LVDS1 --auto --output VIRTUAL --mode 1440x900 --right-of LVDS1
##(this activates the virtual screen on the intel chip - a 1440x900 external display placed to the right of the laptop's internal display)
screenclone -d :8 -x 1
view raw thinkubuntu-6 hosted with ❤ by GitHub

A few seconds after running screenclone, you should have a functional external monitor! If you get a flashing cursor for more than about 5 seconds, something is wrong with your configuration files above, try following the guide again.

Next, we’ll hold the xserver-xorg-video-intel package so that you can update safely without killing your multimon setup.

sudo -s
echo xserver-xorg-video-intel hold | dpkg --set-selections
sudo apt-get update
sudo apt-get upgrade
view raw thinkubuntu-7 hosted with ❤ by GitHub

Finally, to make this usable as a daily-driver, I suggest installing thinkdisp, an indicator applet I developed that automates display on/off, nvidia card on/off, and status checking. You can find the installation guide here (don’t worry, it’s much simpler than this).

Sources

http://zachstechnotes.blogspot.com/2012/04/post-title.html
http://zachstechnotes.blogspot.com/2012/01/tri-head-display-on-linux-thinkpad-w520.html
https://github.com/Bumblebee-Project/Bumblebee/issues/122
https://help.ubuntu.com/community/PinningHowto#Introduction%20to%20Holding%20Packages