NVIDIA binary driver on Xen-enabled Linux x86_64

Posted by: admin  :  Category: Virtualization, Xen

It seems impossible at first to run the NVIDIA binary driver on Linux x86_64 when Xen is enabled.

That’s because NVIDIA does not support Xen in the first place albeit there’s some demand for it for sure.

Luckily the only things to be changed are within the kernel interface contained in the driver package. There exist already a lot of patches on the net, I took mine from nvnews.

You can grab a copy of the patch from my site, too.

The following instructions are derived from my steps in getting NVIDIAS’s binary driver to work on Fedora Core 6 running Xen on the x86_64 platform (Intel Core 2 Duo 6420 CPU).
It was verified to work with driver version 1.0.9755 (march 29, 2007) and 1.0-9639 (may 29, 2007), both of which you can get from the NVidia website.

First you need to have some prerequisites installed on your system:

  • toolchain (gcc, make, etc.)
  • applicable kernel headers (I had kernel 2.6.20-1.2948.fc6xen on my system, so I installed kernel-xen-devel-2.6.20-1.2948.fc6 and kernel-xen-2.6.20-1.2948.fc6 packages)

Then the appropriate driver packages needs to be downloaded and extracted to a temporary directory:

mkdir /tmp/nv_xen
cd /tmp/nv_xen
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/1.0-9639/NVIDIA-Linux-x86_64-1.0-9639-pkg2.run
/bin/sh NVIDIA-Linux-x86_64-1.0-9639-pkg2.run -x
Creating directory NVIDIA-Linux-x86_64-1.0-9639-pkg2
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 1.0-9639.

Also get a copy of the NVidia Patch for XEN:

wget http://phaq2.phunsites.net/wp-content/uploads/2007/06/nvidia_xenpatch.gz

Then change to the source directory, apply the patch and compile the driver.
The kernel source is required. If installed properly it should be located at /usr/src/kernels. If more than one exists choose the right one according to your ‘uname -r’ output.

cd NVIDIA-Linux-x86_64-1.0-9639-pkg2/usr/src/nv
zcat ../../../../nvidia_xenpatch.gz | patch -p4
[output omitted]
make SYSSRC=/usr/src/kernels/2.6.20-1.2948.fc6xen-x86_64/ module
[output omitted]

If the compile run succeeds you should see the message NVIDIA: left KBUILD by the end of the output.
If anything weird happens, e.g. build process aborts, either the patch did not apply cleanly, the headers are not up to date or your sources are not configured.
In the last case a simple ‘make oldconfig’ from the kernel source directory may be enough to get it fixed.
There’s also the chance that you try this patch on a non-supported kernel source version or NVIDIA driver package which may prevent successful compilations.
Since I did not implement the patch by myself I cannot be of much help in either case.

Upon successful compilation you can install and load the driver. Verify that the driver loaded by means of ‘lsmod’.

install -D -o root -g root -m 0644 nvidia.ko /lib/modules/`uname -r`/video/nvidia.ko
depmod -a
modprobe nvidia
lsmod|grep nvidia
nvidia               7771096  22

At this point run the NVIDIA installer to get the remaining utilities.
Use the ‘no-kernel-module’ option as you installed the kernel module already.

cd ../../../
/bin/sh nvidia-installer --no-kernel-module

This is it! You are now ready to configure your X server to use the NVIDIA driver.
Stick to the docs included with the driver on how to achieve this.

This is my Xorg sample configuration with twin-view enabled accross two displays at 1280×1024 resolution.

# sample Xorg configuration file for NVIDIA graphics driver

Section "ServerLayout"
	Identifier	"Default Layout"
	Screen		0  "Screen0" 0 0
	InputDevice	"Keyboard0" "CoreKeyboard"

Section "Module"
	Load	"dbe"
	Load	"extmod"
	Load	"record"
	Load	"xtrap"
	Load	"freetype"
	Load	"type1"
	Load	"glx"

Section "InputDevice"
	Identifier	"Keyboard0"
	Driver		"kbd"
	Option		"XkbModel" "pc105"
	Option		"XkbLayout" "ch"
	Option		"XkbVariant" "de_nodeadkeys"

Section "Device"
	Identifier	"Videocard0"
	Driver		"nvidia"
	Option		"TwinView" "1"
	Option		"CursorShadow" "1"
	Option		"TwinViewOrientation" "RightOf"
	Option		"MetaModes" "1280x1024,1280x1024"

Section "Screen"
	Identifier	"Screen0"
	Device		"Videocard0"
	DefaultDepth	24
	SubSection "Display"
		Depth	24
		Modes	"1280x1024"

9 Responses to “NVIDIA binary driver on Xen-enabled Linux x86_64”

  1. Axel Olmos Says:

    This works. Thank you so much. So far, this version of the Nvidia driver also seems to be more stable on my AMD X2 than newer versions.

  2. Gerhard Lehmann Says:

    Yes! I really thought getting a new video card. Trying over two days to install any driver without succes. I’m very happy that this works now. Thank you.

  3. Luis Torres Says:

    Did anyone try this under different Linux distros and is willing to share the experience? I am interested in knowing about Scientific Linux 5.0 (latest kernel 2.6.18-8.1.8). Thanks.

  4. Drew Farris Says:

    Thanks for the great instructions.

    I confirmed that this works with CentOS 5 with NVIDIA-Linux-x86-1.0-9755 and kernel 2.6.18-8.1.8.el5xen and a Quadro NVS280 on a Dell Dimension 470n, but it is very slow because MTRR are used instead of PAT.

    I will be better off running a non-xen kernel and hosting my xen instances on another headless machine.

  5. Paul Says:

    This patch doesn’t work on the latest RHEL 5.1 Xen Kernel 2.6.18-53.1.13.el5.

    The nvidia_xenpatch on the latest NVIDIA-Linux-X86_64-169.12 driver failed to apply. The path did apply on the NVIDIA-Linux-X86_64-10-9639 driver, and tried the xorg.conf example and also using the nvidia-xconfig script, but both gave me the “could not open the device file /dev/nvidia0 (Input/output error)”, although the device file exists.

  6. Michael M Says:

    Once again,Linux earns an F. I understand all the arguments about who is responsible,but the long and the short of it is,my time is valuable and these kinds of problems show that linux simply isn’t ready for prime time. Yes,I CAN make it work,but having to install three times and then Google some obscure patch to make functionality that is supposed to work,actually be usable is just ridiculous.
    For all its faults,windows actually does work out of the box on most hardware. If you need Unix,there are allways Macs,which once again,work,in fact many say they work better than windows,but of course Apple controls the hardware. There is of course also Solaris,which I have very few problems installing on both Sun and commodity hardware. Yet we are still told that somehow linux is a viable option for real professional uses. I just dont see it.

    BTW, This is a “junk” ,machine made from spare parts,buts rather up to date,core 2 duo e6600,ecs 945p motherboard, 3gigs of ram and an NVIDIA graphics card,which I bought because all the linux fanboys say it has better support than ATI,which coincindentally,’works’ in Xen with no crazy patches. Of course getting it to work at all took quite a bit of work,but thats another story.

  7. Michael M - Moron Says:

    Way to keep it on topic Michael M. Go and whinge someplace else, what do you hope to achieve with such pessimism and negativity?

  8. sbeam Says:

    Michael, get a hold of yourself. Xen is a relatively new tech and Nvidia is a company that goes to lengths to support Linux, its just that there is a gap in support for Xen kernels. You are probably using the open source ATI drivers which have been updated. Maybe you should take your complaint up with nvidia, not troll around bashing the whole OS because you had to learn something.

    If you can’t handle the simple instructions in this howto then yes you should be using a Mac and being satisfied with simple stuff. Plenty of professionals and smart people use linux, it works for those of us who are capable of understanding how to use it.

  9. laing Says:

    You don’t need a patch to get the nvidia driver working with a xen kernel. Here’s how I do it:
    First download and install the nvidia driver under a NON-xen kernel. The driver can be obtained from the nvidia unix drivers portal page at: http://www.nvidia.com/object/unix.html. This process should be fairly self explanatory.
    Next boot your xen kernel and extract the nvidia driver source tree from the file you downloaded and installed above: (eg. NVIDIA-Linux-x86_64-xxx.xx.xx-pkg2.run -a -x)
    Now change to the newly created directory: cd NVIDIA-Linux-x86_64-xxx.xx.xx-pkg2/usr/src/nv
    Build your driver module as follows: IGNORE_XEN_PRESENCE=y make SYSSRC=/lib/mod
    ules/`uname -r`/build module
    Next you make a home for the newly built module and copy it to the right place:
    mkdir /lib/modules/`uname -r`/video
    cp -ip nvidia.ko /lib/modules/`uname -r`/video/
    Now load the driver as follows: depmod -a
    Now restart your display manager so it will try to load X again with the video driver in place:
    killall -HUP gdm-binary
    In a few seconds you should be up and running. Have fun.