Thursday, 30 August 2012

Enabling external monitor on Lenovo W530 with Nvidia Discrete Graphics and Ubuntu Linux 12.04

I've recently acquired a Lenovo W530 laptop. It's nice. Running Ubuntu 12.04 and with 32GB of RAM and an SSD it builds Firefox with cold/empty caches in 14 minutes flat, which is pretty good!

It was a trial figuring out how to get the Nvidia graphics card and a second monitor working however. The current Ubuntu stable nvidia-current package doesn't include support for the Quadro K1000M chipset, and the official Nvidia drivers available from Nvidia.com didn't work for me, and left my libGL.so's missing when I uninstalled them.

I eventually figured out the steps to get a compatible Nvidia driver installed and displaying a second monitor:

1. Install the "X Updates" team's PPA, and install the latest Nvidia drivers, which supports the Quadro K1000M. In the terminal enter:
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current
2. Reboot. At the Lenovo BIOS screen press "Enter" to interrupt normal startup, F1 to enter BIOS setup utility. Change Config > Display > Graphics Device to Discrete Graphics. This means the hardware will attempt to use only the Nvidia graphics card, not the Intel integrated graphics. Press F10 to save and boot the computer.

3. Once you've booted up and logged in, to setup multiple monitors you'll need to run nvidia-settings from the terminal as root:
sudo nvidia-settings
Setup your displays in the "X Server Display Configuration" tab (you may need to "Detect Displays" first, and you probably want "TwinView" configuration). Once you've configured your displays, make sure you "Save to X Configuration File". When I saved my config file the path save was blank. If this happens to you, enter: /etc/X11/xorg.conf

3. (Updated 13 October 2012) Once you've booted up and logged in, you can use Ubuntu's "Displays" application to easily configure your secondary displays. Note that if you use nvidia-settings to write an xorg.conf (as I previously suggested) X won't detect when you unplug a monitor, and so when you unplug a monitor X may open windows on the monitor which is no longer connected, i.e. where you can't see them, which can be very inconvenient!

4. To get your hardware brightness keys working (i..e Fn+F8/F9), edit the /etc/X11/xorg.conf file as root:
sudo gedit /etc/X11/xorg.conf 
...and add the following line to the "Device" section for the "Quadro K1000M":
    Option         "RegistryDwords" "EnableBrightnessControl=1"
Log out/log back in and then your brightness keys should work!

4. (Updated 13 October 2012) To get your display brightness keys working (i..e Fn+F8/F9) you need to tell the Nvidia graphics driver to enable the brightness controls.

These days X automatically configures itself, so you can't just edit the xorg.conf file, you instead need to add a section to a file in /usr/share/X11/xorg.conf.d/ and X will include that section in the configuration that it automatically generates.

So to get the screen brightness keys working with your Nvidia graphics card, create a file in the xorg.conf.d directory, e.g:
sudo gedit /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf

Paste the following into the file:
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro K1000M"
    Option         "RegistryDwords" "EnableBrightnessControl=1"
EndSection
Log out and log back in, or reboot, or simply kill X with CTRL+ALT+BACKSPACE, or ALT+PrtSc+K, and your brightness keys should now work!

Caveat: I've only had a second monitor working on my VGA output, I'm looking forward to my mini-DVI adapter arriving so I can have a cripser DVI output. Hopefully that will Just Work....

Update 13 October 2012: a second monitor Just Worked with my mini-DVI adapter. I was able to get two external displays running off a docking station. Possibly the docking station could drive more, I haven't felt the need, three displays is enough for me!

And unfortunately my laptop refuses to boot with Discrete Graphics enabled, the Nvidia driver installed, and with virtualization enhancements enabled in the BIOS. Apparently it is possible with the help of the BumbleBee project however.

Update 13 October 2012: I was able to boot with virtualization enhancements enabled in BIOS if I specified the nox2apic kernel command parameter. I haven't done enough research to figure out whether disabling x2apic is a good idea or not.

37 comments:

Alex Gyori said...

I tried following your suggestions but my laptop does not boot at all when i switch to discrete graphics.

I see you mention that in your post. How did you overcome that?

Thank you.

Chris Pearce said...

@Alex: I was unable to boot with discrete graphics turned on until I'd installed the new drivers from ubuntu-x-swat/x-updates.

i.e.: Install the ubuntu-x-swat/x-updates drivers, then switch to discrete graphics in BIOS.

If you've installed the ubuntu-x-swat/x-updates drivers and still can't boot in discrete mode, then you're seeing something I didn't encounter. :(

Pavius said...

Thanks for the info, Chris. I used disper before I read this and this is much more convenient. Here are a few bits of additional info:

1) I got this working on a W530 w/K1000M with three monitors - displayport, VGA and the laptop monitor. Everything works after using the driver from the ppa with no need to run nvidia-settings (sans brightness control)
2) This also works on a W520 w/K1000M, but I only tested dual screen - displayport and laptop
3) I don't do the switch to discrete after getting the drivers, rather before Ubuntu installation. Worked fine for several installations on both W520s and W530s (I all but gave up on Optimus - battery life is good enough for me)
4) I read your blurb about virtualization and was sure it was enabled. Apparently it wasn't, and I shakingly enabled it on the W530 only to boot fine. On the W520 it was enabled during installation and it works fine
5) I used Ubuntu 12.04.1 for all the above

Justin Gordon said...

Did you investigate the package nvidia-current-updates?

Chris Pearce said...

@Pavius: Thanks for your info. I too have now stopped using nvidia-setting to configure multiple monitors, and am just using the Ubuntu displays utility.

@Justin: I haven't tried nvidia-current-updates. I might try it next time.

Chris Alix said...

Thanks for the excellent information. My W530 showed up today and your post was a great help.

Specifying the "nox2apic" kernel boot argument seems to make the W530 boot 12.04 with Discrete Graphics and Virtualization/VT-D enabled. This appears to be a manifestation of a known bug in the ThinkPad BIOS; details and advocacy encouraging Lenovo to fix it are here:

http://bugs.launchpad.net/ubuntu/+source/linux/+bug/776999/comments/60

http://forums.lenovo.com/t5/Linux-Discussion/W520-Debian-64-bit-Testing-VT-enabled/td-p/671621

http://forums.lenovo.com/t5/W-Series-ThinkPad-Laptops/W520-BIOS-Bug-Please-fix-or-comment-Lenovo/td-p/802085

Andreas Wiik said...

I still can't boot in discrete graphics mode. No matter what I do, I just get "No screens found" error from xorg.

I now have the 304.51 version of the Nvidia driver installed, but no luck.

I tried disabling the Virtual settings in bios.

Andre Mastrangelo said...

Thank you!

I came here through your post in askubuntu.com.

Thank you very much I was going crazy.

Ciao
Andre

Arny80Hexa said...

I have get my W530 with K2000M yesterday and i have some truble with Ubuntu 12.10.
I have installed the nvidia-current and bumblebee from x-swat team and it seems to beworking but i don't get a secont Monitor running. So i have found your Post and a have tried to change the graphics from Optimus to Discrete graphics in BIOS.
After that Ubuntu shows the login-screen and when i logged into the system i only see the desktop background. No Icons, no Tasbar, nothing.
On Pressing [Ctrl]+[Alt]+[T] i get the Console to reboot the system. That was the only Thing.

I'm thinking of rolling back to Ubuntu 12.04.1 and testing again, but i hope someone have the same Problem and fixed it, so can help me.
Thanks, Arny

Arny80Hexa said...

I have get my W530 with K2000M yesterday and i have some truble with Ubuntu 12.10.
I have installed the nvidia-current and bumblebee from x-swat team and it seems to beworking but i don't get a secont Monitor running. So i have found your Post and a have tried to change the graphics from Optimus to Discrete graphics in BIOS.
After that Ubuntu shows the login-screen and when i logged into the system i only see the desktop background. No Icons, no Tasbar, nothing.
On Pressing [Ctrl]+[Alt]+[T] i get the Console to reboot the system. That was the only Thing.

I'm thinking of rolling back to Ubuntu 12.04.1 and testing again, but i hope someone have the same Problem and fixed it, so can help me.
Thanks, Arny

Chris Pearce said...

@Arny80Hexa: I've had that sort of thing happen several times when messing with settings. Often deleting (or renaming if you don't want to delete) your ~/.gnome2/ or ~/.gconf/, or some other ~/.$config/ directories enables Ubuntu to re-init its settings and reconfigure correctly. I can't unfortunately remember exactly which directory to delete, you'll need to experiment.

Arny80Hexa said...

Hi Chris and thanks for fast response. Here my experiences:

After spending one working-day I have solved all my Problems and Ubuntu 12.10 with KDE workes fine whith a second Monitor on my W530 N1K43GE.

At this Time I don't know, where was the Problem but here ist my short tutorial, how to do a fresh Install of Ubuntu, and I hope anyone help this:

1) Go to BIOS. Set Graphics Device to nVidia Optimus and OS auto detection to Disable. Virtualization turning to Disable.

2) Install Ubuntu or Kubuntu (like me) or what ever you prefer.

3) activate the Ubuntu partner repository and do a full dist-upgrade of your system. Reboot

4) atm there is no repository for quantal!!! So I have installed the nvidia-current form ubuntu repo.

5) Create the /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf and fill whith the content like shown above. (If I hadn't this, my system was freezing on pressing [Fn]+[F8/F9])

6) Edit the /etc/default/grub and set the nox2apic as default boot parameter. Do update-grub.

7) Go to BIOS. Change Graphics Device to Discrete. Os auto detection still stays at Disable! Now you can turn on the Virtualization. Safe all settings and boot in you Ubuntu.

Now everything is fine. And I can work with multi-monitor.

Notes:

- Bootscreen of Ubuntu look terrible. Very low resolution and colors. Some system output is showing on sceen.
- Before the LoginScreen is shown now I can see a half second the nVidia-Logo.
- I think my fan don't make more noise while running permanently on Dedicated Graphic. While I'm writing this comment he is also turning off. Not more noise than running on Windows Desktop (which I have for gaming on an second HDD in UltraBay, Ubuntu-System is on SSD)
- I have some trouble whith my Logitech Unifying-Reciver. After a Reboot I have to take it out of my notebook and put it in again befor I can use my mouse. I hope I find a solution.
- I have tested also the new Kernel 3.6 like written on this tutorial: http://www.upubuntu.com/2012/10/install-linux-kernel-36-on-ubuntu.html Workes fine!

Ciao
Arny

Francois van der Ven said...

Hi, thanks for the tutorial. I have a W520 with nVidia 1000M and I've tried to migrate from Windows (8) to Ubuntu but I gave up because I couldn't get nVidia optimus to work correctly. Battery life is important to me as I don't always have access to external power. Now I haven't tried with discrete only mode yet and I was wondering - how good is battery life with that? On my current Windows 8 install I get about 5/6 hours before it goes dead so I hope it's close to that. Thanks!

Chris Pearce said...

I find battery life is better on integrated mode than on discrete mode, and the driver is more reliable. I've never gotten Optimus mode working under Linux, so I can't tell you how good that is.

Francois van der Ven said...

But what I wanted to know was the battery life with discrete only mode, about how many hours can it go without being plugged into a power source?

Chris Pearce said...

Unfortunately I never measured this, as I'm not away from a power source much with my w530. However IIRC the estimated battery power/time remaining was better in integrated mode than discrete, which implies that it would be better in optimus mode too. The fan was also quieter in integrated mode, implying the system isn't using as much power.

deleted said...

Does anyone have this working on 12.10?

I followed these instructions, but when I reboot after switching to discrete graphics in the bios, I have a really small resolution, and then Ubuntu fails to load properly. It just gets stuck after I log in.

Any ideas? Thanks.

3dto2dnoob said...

Hey guys I need help. New to Linux and I also have the thinkpad w530. I have red hat linux enterprise open client. Will this work for me?

-I am not a robot

3dto2dnoob said...

Hi I'm new to Linux and I have Red Hat Enterprise open client. Will this work? Just tryiing not to mess up a good thing right now.

Chris Pearce said...

@deleted: When I upgraded to 12.10 using the update utility, it Just Worked. You don't need the ubuntu-x-swat/x-updates PPA, as nvidia-current on 12.10 has support for this hardware.

@3dto2dnoob: These instructions are for Ubuntu, but the basic idea still applies.

deleted said...

@Chris

Thanks for the reply. Glad it works for you. Neither me, nor dholbert could get it working on 12.10 :-/

Swapping the lenovo for a macbook :(

-fitzgen

Pavius said...

Here's an update after about 4 months of use - I ditched Ubuntu as the host OS and now run it as a guest atop a Win7 host.

There were so many different stability issues with Ubuntu 12.04 (most of which seemed to be display related) that after several re-installs I decided it wasn't worth it.

Pavius said...

Here's an update after about 4 months of use - I ditched Ubuntu as the host OS and now run it as a guest atop a Win7 host.

There were so many different stability issues with Ubuntu 12.04 (most of which seemed to be display related) that after several re-installs I decided it wasn't worth it.

张宗平 said...

Thanks your great effort. I have nvidia 310.32 driver installed with ubuntu 12.10 x64 on my w530 with K1000m. Other things works fine except that backlight cannot be adjusted even with your guide on enable backlight adjustment. Press the backlight key can change the value of brightness file, but without any visible effects.

Chris Alix said...

A little off-topic, since I gave up on Ubuntu 12.04 and ran Centos, but as another data point, here is a configuration that is working fine, including a second monitor on the VGA port. It has the added advantage of coming with good old Gnome 2, as well. :-)

Lenovo W530 with nVidia Quado K2000, Discrete Mode graphics and VT-x enabled in BIOS, Centos 6.3 x86_64, "nox2apic" kernel bootarg, kmod-nvidia (310) and nvidia-x11-drv and nvidia-x11-drv-32bit packages from ELRepo.

Arny80Hexa said...

@Francois van der Ven:

Now i'm working a few month with Kubuntu on the W530 and the Battery-Life is mostly like on Windows 7.

In Office-Mode (WLAN on, Keyboard-Light on, Display-Brightness 50%, browsing on web or writing some Dokuments, hearing music) it is round about 6-7 hours.

When im turning off the Keyboard-light and setting display-brigntness to the lowest, then sometimes the Batterie-Lifetime reaches 8 hours, maybe more.

That is enough for me.

Only the lower Performance than in cable-mode sucks. On Minecraft it switches between 35+ FPS (cable mode) and 15 or less FPS in batterie-mode)

hope it hepls

@deleted: do you have turned off the auto-os-detection in BIOS?

Francois van der Ven said...

@Arny80Hexa
Thanks for your reply :) I made the switch to Kubuntu a month ago and I'm still very happy I did so. Battery life is indeed no problem, just like you said. And I also noticed that (especially) ingame the performance differs if you're connected to AC or not. Haven't found out how to disable this yet..

Jack O'Connor said...

THANK YOU! for the brightness fix. I ran into this issue on Arch, and I switched to Ubuntu assuming it would work there (with the proprietary drivers), but no dice. With your fix it works, and now I want to try the same fix on Arch :)

Chris Pearce said...

My colleague was able to get his screen's brightness changing by adding the following kernel boot options:

acpi_backlight=vendor thinkpad-acpi.brightness_enable=0

JA said...

Got the second display working (albeit in a not-so-great resolution) then tried the brightness key fix and now the second monitor won't pick up. Any suggestions?

Chris Pearce said...

@JA: No idea sorry.

Chris Bulmer said...

How did you overcome the issue where you could unplug a monitor but the laptop would still try and display windows on it?

Chris Pearce said...

@Chris Bulmer: I didn't. :( I'd move all my windows onto the internal display before unplugging.

Gideon Rosenthal said...

Thanks for the tutorial. Helped me out a bunch.

Gaël Pouzerate said...

You saved my day after 6 hours trying in vain!!! Thanks so much!!!

Gary said...

posting from windows as I broke my xconfig settings and can't boot Ubuntu up anymore.. going to give it another go.. funny thing is I can't change the virtualization settings (I assume its the one on the security tab)

Gil said...

This worked perfectly for me. Thanks!!!