In my last post I mentioned that I recently had a hardware failure that took down my server. I needed to get it back up and running again ASAP, but due to a large number of complications I was unable to get the original hardware up and running again, nor could I get any of the three other systems I had at my disposal to work properly. Seriously, it was like Murphy himself had taken up residence here. In the end, rather desperate and out of options, I turned to Xen (for those unfamiliar with it, it's similar to VMware or Virtual Box, but highly geared towards server0. I'd recently had quite a bit of experience getting Xen running on another system, so I felt it'd be a workable, albeit temporary, solution to my problem.
Unfortunately, the only working system I had suitable for this was my desktop, and while the process of installing and migrating the server to a Xen guest host was successful (this site is currently on that Xen instance) it was not without it's drawbacks. For one thing, there's an obvious performance hit on my desktop while running under Xen concurrently with my server guest, though fortunately my desktop is powerful enough that this mostly isn't an issue (except when the guest accesses my external USB drive to backup files; for some reason that consumes all CPU available for about 2 minutes and kills performance on the host). There were a few other minor issues, but by far the biggest problem was that the binary nVidia drivers would not install under Xen. Yes, the open source 'nv' driver would work, but that had a number of problems/limitations:
- dramatically reduced video performance, both in video playback and normal 2d desktop usage
- no 3d acceleration whatsoever (remember, this is my desktop system, so I sometimes use it for gaming)
- no (working) support for multiple monitors
- significantly different xorg.conf configuration
In fairness, issues 1 and 2 are a direct result of nVidia not providing adequate specifications for proper driver development. Nonetheless, I want my hardware to actually work, so the performance was not acceptable. Issue 3 was a major problem as well, as I have two monitors and use both heavily while working. I can only assume that this is due to a bug in the nv driver for the video card I'm using (a GeForce 8800 GTS), as dual monitors should be supported by this driver. It simply wouldn't work, though. Issue 4 wasn't that significant, but it did require quite a bit of time to rework it, which was ultimately pointless anyway due to issue 3.
So, with all that said, I began my quest to get the binary nVidia drivers working under Xen. Some basic searches showed that this was possible, but in every case the referenced material was written for much older versions of Xen, the Linux kernel, and/or the nVidia driver. I tried several different suggestions and patches, but none would work. I actually gave up, but then a few days later I got so fed up with performance that I started looking into it again and trying various different combinations of suggestions. It took a while, but I finally managed hit on the special sequence of commands necessary to get the driver to compile AND load AND run under X. Sadly, the end result is actually quite easy to do once you know what needs to be done, but figuring it out sure was a bitch. So, I wanted to post the details here to hopefully save some other people a lot of time and pain should they be in a similar situation.
This guide was written with the following system specs in mind:
- Xen 3.2.1
- Gentoo dom0 host using xen-sources-2.6.21 kernel package
- a non-Xen kernel must also be installed, such as gentoo-sources-2.6.24-r8
- GeForce 5xxx series or newer video card using nvidia-drivers-173.14.09 driver package
Version differences shouldn't be too much of an issue; however, a lot of this is Gentoo-specific. If you're running a different distribution, you may be able to modify this technique to suit your needs, but I haven't tested it myself (if you do try and have any success, please leave a comment to let others know what you did). The non-Xen kernel should be typically left over from before you installed Xen on your host; if you don't have anything else installed, however, you can do a simple
emerge gentoo-source to install it. You don't need to run it, just build against it.
Once everything is in place, and you're running the Xen-enabled (xen-sources) kernel, I suggest uninstalling any existing binary nVidia drivers with
emerge -C nvidia-drivers. I had a version conflict when trying to start X at one point as the result of some old libraries not being properly updated, so this is just to make sure that the system's in a clean state. Also, while you can do most of this while in X while using the nv driver, I suggest logging out of X entirely before the
Here's the step-by-step guide:
uname -rto verify the version of your currently running Xen-enabled kernel; eg., mine's 2.6.21-xen
- verify that you have both Xen and non-Xen kernels installed:
cd /usr/src/ && ls -l
- eg., I have both linux-2.6.21-xen and linux-2.6.24-gentoo-r8
- create a symlink to the non-Xen kernel:
ln -sfn linux-2.6.24-gentoo-r8 linux
- install the nVidia-drivers package, which includes the necessary X libraries:
emerge -av nvidia-drivers
- this will also install the actual driver, but it'll be built and installed for the non-Xen kernel, not your current Xen-enabled kernel
- determine the specific name and version of the nVidia driver package that was just installed; this can be found by examining the output of
emerge -f nvidia-drivers(look for the NVIDIA-Linux-* line)
- extract the contents of the nVidia driver package:
bash /usr/portage/distfiles/NVIDIA-Linux-x86_64-173.14.09-pkg2.run -a -x
- change to the driver source code directory:
- build the driver for the currently-running Xen-enabled kernel:
IGNORE_XEN_PRESENCE=y make SYSSRC=/lib/modules/`uname -r`/build module
- assuming there are no build errors (nvidia.ko should exist), install the driver:
mkdir /lib/modules/`uname -r`/video
cp -i nvidia.ko /lib/modules/`uname -r`/video/
- if necessary, log out of X, then load the driver:
- if necessary, reconfigure xorg.conf to use the nvidia binary driver rather than the nv driver
- test that X will now load properly with
- if appropriate, start (or restart) the display manager with
Assuming all went well, you should now have a fully functional and accelerated desktop environment, even under a Xen dom0 host. W00t. If not, feel free to post a comment and I'll try to help if I can. You should also hit up the Gentoo Forums, where you can get help from people far smarter than I.
I really hope this helps this helps some people out. It was a royal pain in the rear to get this working, but believe me, it makes a world of difference when using the system.