Author Topic: ThinkPad w520 & Ubunut 12.10 x64 - Multi-Monitor Setup (VGA TESTED ONLY)  (Read 463 times)

ArmyHill01

  • Administrator
  • Newbie
  • *****
  • Posts: 11
    • View Profile
So this has been in the works for over a month. I started on this mission after experiencing Windows 8 and feeling whole heartily there MUST be an alternative.

Say it with me, Hello Ubuntu!

Overview:
The W520's use nVidia Optimus to save battery life and keep the PC cool. This is great except for the fact that nVidia refuses to support Optimus in Linux. Not cool nVidia. This is a major issues as the W520's external ports, both VGA & Display Port, are literally wired to the nVidia card. This means if you set the BIOS to only use the Intel GPU, you lose all ability to have additional monitors. Flipping that around and enabling Discrete Graphics in the BIOS presents another issue in the form of a bug. With Discrete Graphics and Intel's Virtualization settings turned on, a bug presents Linux from booting. Linux developers are finally tracking and planning a fix for this but Lenovo literally refuses to fix the issue and will not even acknowledge the fact they have caused the bug. Way to go Lenovo.

At this point I knew i had to get Optimus to work in order to not only save my battery and PC's life through lower temps, but I absolutely need to have at least one additional monitor.

The search began...

Resources:
I found the following resources and discovered what i needed has been accomplished in Ubuntu 12.04 x64 & 12.10 with similar model ThinkPad's. I read a ton of other articles related to how Optimus actually works on a hardware level and why Linux has, thus far, been unable to accomplish what Windows can do so easily.
These sites eventually led me to typing this on my external monitor. I take no credit for any of the creativity as the guys who wrote the articles are the real innovators/inspires.

1. http://blog.echo-flow.com/2012/08/04/thinkpad-w520-multi-monitor-nvidia-optimus-with-bumblebee-on-ubuntu-12-04/
2. http://sagark.org/optimal-ubuntu-graphics-setup-for-thinkpads/
3. https://github.com/liskin
4. http://zachstechnotes.blogspot.com/2012/04/post-title.html
5. https://wiki.ubuntu.com/Bumblebee#Installation
6. http://www.webupd8.org/2012/08/get-hdmi-working-with-nvidia-optimus-on.html
7. https://github.com/Bumblebee-Project/Bumblebee/wiki/Multi-monitor-setup
8. http://blog.gordin.de/post/optimus-guide
9. Google, a lot of Googling

Major, MAJOR props to all the above authors. I couldn't have done it without these articles!

The Setup:
This is my setup and how I made everything work. If you try something else, that's fine, just remember this is how I succeeded.

1. Install Ubuntu 12.10 x64. Reboot and install any updates.
2. Open Ubuntu Software Center and search for GNOME. Install "The GNOME Desktop Environment, with extra components". During the installation a popup will ask which desktop to use, choose GDM, not the lightDM)
3. Reboot and click the icon to the right of your name and choose GNOME.

Now the fun begins...

4. Install Bumblebee using the this (https://wiki.ubuntu.com/Bumblebee#Installation).
I'll include the steps for archival reasons as well.

Open a Terminal (Ctrl + Alt + T) and highlight the following text and drag it to the terminal:

Code: [Select]
sudo add-apt-repository ppa:bumblebee/stable
Code: [Select]
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
Code: [Select]
sudo apt-get update
Code: [Select]
sudo apt-get install bumblebee bumblebee-nvidia linux-headers-generic
Reboot and log into GNOME.

5. Now test that everything installed correctly using the following commands in a terminal.

Code: [Select]
glxspheres      i. This should open new window and display graphics. Take note of the measurement.

Hit Ctrl + C in the terminal to end that task and now run

Code: [Select]
optirun glxspheres      ii. You should notice the measurement is almost 5x times faster. This is your nVidia card :)

Quote
If the above commands DO NOT work, you need to uninstall everything, reboot and try again.

Run the following in a terminal:

6.
Code: [Select]
sudo apt-get install xorg-dev7.
Code: [Select]
sudo apt-get install git
Now reboot again and log back into GNOME.

Almost done!

Now it's time to install and patch the Intel Driver. Enter the following in a terminal:

8.
Code: [Select]
sudo apt-get build-dep xserver-xorg-video-intel9.
Code: [Select]
sudo apt-get source xserver-xorg-video-intel10.
Code: [Select]
cd xserver-xorg... (Hit tab to autocomplete the command)
11.
Code: [Select]
sudo wget https://raw.github.com/liskin/patches/master/hacks/xserver-xorg-video-intel-2.20.2_virtual_crtc.patch12.
Code: [Select]
sudo patch -p1 < xserver-xorg-video-intel-2.20.2_virtual_crtc.patch13.
Code: [Select]
sudo dpkg-buildpackage -b14.
Code: [Select]
cd15.
Code: [Select]
sudo dpkg --install xserver-xorg-video-intel_2.20.9-0ubuntu2_amd64.deb #(again, hit tab to autocomplete the command)

Reboot again and log back into GNOME.

16.
Code: [Select]
git clone git://github.com/liskin/hybrid-screenclone.git17.
Code: [Select]
cd hybrid-screenclone18.
Code: [Select]
sudo make19.
Code: [Select]
sudo cp screenclone /usr/bin/20.
Code: [Select]
sudo chmod +x /usr/bin/screenclone21.
Code: [Select]
sudo cp xorg.conf.nvidia /etc/bumblebee/xorg.conf.nvidia22.
Code: [Select]
sudo rm /etc/X11/xorg.conf
Quote
#22 Will probably give you an error the file does not exist, this is fine.

23.
Code: [Select]
sudo gedit /etc/bumblebee/bumblebee.conf   1. Use Ctrl + F to search for and change the following settings

Quote
   Driver=nvidia
   PMM=bbswitch

Click save(Ctrl + S) and close gedit.

Now the following command should, and I say should ,turn on the external display and, after a few seconds, display a twin view of your Ubuntu desktop.

Code: [Select]
xrandr --output LVDS1 --auto --output VIRTUAL --mode 1920x1080 --left-of LVDS1
optirun screenclone -d :8 -x 1
xrandr --output VIRTUAL --off

Quote
My monitor isn't 1080p so i changed the --mode to my monitors max. resolution of 1680x1050.
Now this command isn't all that practical for everyday use so I made a script to do it all for me.

Here are the last two steps:

My resource: (https://help.ubuntu.com/community/Beginners/BashScripting)

Open Gedit, copy the following code and save the file somewhere easily accessiable.

Code: [Select]
#!/bin/bash

echo "Enabling 2nd Monitor!"

xrandr --output LVDS1 --auto --output VIRTUAL --mode 1680x1050 --left-of LVDS1
optirun screenclone -d :8 -x 1
xrandr --output VIRTUAL --off

Now in order to make this file executable, we need to change its permissions.

Open another terminal and navigate to where you saved it. I saved mine to the Desktop

Example:
Code: [Select]
cd ~/Desktop
Once your in the folder with the file do:

Code: [Select]
chmod +x YourFileNameHere
The last, LAST step. This is IMPORTANT!

Quote
In order to keep the Intel driver safe during updates, do the following in a terminal:

Code: [Select]
sudo -s
Code: [Select]
echo xserver-xorg-video-intel hold | dpkg --set-selections
Code: [Select]
sudo apt-get update
Code: [Select]
sudo apt-get upgrade
I hope this helps other save some time and the major headaches this caused me. Enjoy!

My Setup
http://www.HillsPCWorld.com/forum/pics/LinuxTut/Ubuntu-Dual-Monitor.jpg
Jon Jenson Setup
http://www.HillsPCWorld.com/forum/pics/LinuxTut/Jon-Jenson.jpg
TeeKay Kern
http://www.HillsPCWorld.com/forum/pics/LinuxTut/TeeKay-Kern.jpg
« Last Edit: September 28, 2013, 08:03:01 PM by ArmyHill01 »