Tag Archive for 'nvidia'

Building NVIDIA akmod package for RHEL/CentOS using Fedora and mock

Unfortunately there are no NVIDIA driver packages for RHEL/CentOS available on RPMFusion (that I could find), so this is how I built them. Disclaimer: This is just the way I did it and is probably dodgy. Suggestions welcome.

I have a dedicated build server and use mock so that all of the building is kept separate from my running system in a chroot environment. Packages are built against epel (Extra Packages for Enterprise Linux) and I’m using 64 bit.

We’re building an akmod package (rather than a static kmod) which will push the compilation of the driver on a per kernel basis to the client. The benefit of this is you only need to install the akmod once and the system will compile the kmod drivers after every kernel update.

Install Fedora
Install Fedora and then configure RPMFusion repositories (free, free-updates, non-free, non-free-updates).

Install mock and add yourself to the mock group (replace [username]). Log out and in or run newgrp:
$ sudo yum install mock
$ sudo gpasswd -a [username]
$ newgrp mock

Create a temporary location to perform the tasks below (makes copy and paste from here easier)
$ mkdir ~/building-nvidia
$ cd ~/building-nvidia

Source RPMS
Now we’re ready to get the source RPMs:
$ yumdownloader --source akmod-nvidia akmods buildsys-build-rpmfusion-kerneldevpkgs-current kmodtool libvdpau nvidia-kmod-common nvidia-settings nvidia-xconfig

Initialise mock
Let’s initialise the chroot environment for epel:
$ mock -r epel-6-x86_64 --init

Build and install dependencies
Ordinarily, building an RPM using mock will automatically install any build dependencies into the chroot. By default however it can (obviously) only automatically install any packages that are available in the target distribution. This presents a little problem with RHEL and CentOS because some of the dependencies (such as kmodtool and akmods) are not available in these distributions. So, how do we get around this? We can tell mock to install any RPM we like into the chroot, they don’t have to be available in the target distribution.

But it gets a little more tricky. If said dependency doesn’t exist for RHEL/CentOS, then we need to build it (using mock) and then install it into mock’s chroot manually. Make sense?

Once we have these dependencies manually installed the trick is telling mock not to clean the chroot environment for any post build processes, else it would remove those dependencies we manually installed (and therefore you couldn’t build the packages!).

Building kmodtool
The first dependency we need to build is kmodtool, because it does much of the grunt work for kmods (akmods requires this). Note we will add the “–no-clean” option when building packages, as we don’t want the packages we installed to be removed from the chroot (they’re dependencies).

Go for it:
$ mock -r epel-6-x86_64 --no-clean --no-cleanup-after --resultdir=/var/lib/mock/epel-6-x86_64/result/ --rebuild kmodtool*.src.rpm

Installing kmodtool
Install kmodtool into the chroot:
$ mock -r epel-6-x86_64 --install /var/lib/mock/epel-6-x86_64/result/kmodtool*.noarch.rpm

Building akmods
It gets slightly more tricky. The akmods package we are using is designed for Fedora and fails to build because it can’t detect the version of Fedora we are using and so tries to use systemd (Fedora’s boot system) which is not yet used in RHEL/CentOS. This means we need to install the akmod source rpm, modify the spec file and then re-create the source rpm for compilation (this will happen in your home directory).
$ rpm -ivh akmods*.src.rpm
$ sed -i 's/%fedora\ <=16/0%{?rhel}/g' ~/rpmbuild/SPECS/akmods.spec
$ rpmbuild -bs ~/rpmbuild/SPECS/akmods.spec
$ mock -r epel-6-x86_64 --no-clean --no-cleanup-after --rebuild --resultdir=/var/lib/mock/epel-6-x86_64/result/ ~/rpmbuild/SRPMS/akmods*.src.rpm

This will build akmods RPM and place it in mock's result dir which we will install next.

Installing akmods
Install akmods into the chroot:
$ mock -r epel-6-x86_64 --install /var/lib/mock/epel-6-x86_64/result/akmods*.noarch.rpm

Building buildsys-build-rpmfusion
The kmod package has some smarts to work out which kernel to build the kmod for. We need to build and install the buildsys-build-rpmfusion package which will give us an akmod compatible version of the package (actually it's a "provides"). This also requires kmodtool, hence we had to do this after the others:
$ mock -r epel-6-x86_64 --no-clean --no-cleanup-after --resultdir=/var/lib/mock/epel-6-x86_64/result/ --rebuild buildsys-build-rpmfusion*.src.rpm

Installing buildsys-build-rpmfusion
We only want to install the base package (not the 'current' package as that would require kernel-devel for your Fedora kernel).
$ rm /var/lib/mock/epel-6-x86_64/result/buildsys-build-rpmfusion-kerneldevpkgs-current*.x86_64.rpm
$ mock -r epel-6-x86_64 --install /var/lib/mock/epel-6-x86_64/result/buildsys-build*.x86_64.rpm

That's it for manual dependencies!

From now on, the packages we build will not be installed into the chroot, they will be copied and installed on the client machine.

Building nvidia-kmod package
The spec file for the nvidia-kmod package has a "buildforkernels" definition to tell it what kernel you want to build for, either current or latest kernel. Alternatively, it can build an akmod package (dynamically build package on boot), which is what we want. By default this option is set to "current" so we need to change this definition to "akmod" (hard-coded in the spec file).

To do this, we need to install the source RPM, change the option in its spec file, and rebuild the SRPM:
$ rpm -ivh nvidia-kmod*src.rpm
$ sed -i s/^%define\ buildforkernels\ current/%define\ buildforkernels\ akmod/ ~/rpmbuild/SPECS/nvidia-kmod.spec
$ rpmbuild -bs ~/rpmbuild/SPECS/nvidia-kmod.spec
$ mock -r epel-6-x86_64 --no-clean --rebuild ~/rpmbuild/SRPMS/nvidia-kmod*.src.rpm

If you don't want an akmod, then you need to specify the kernel that you're building for (this should install kernel-devel into the chroot). If you don't, you'll run into problems because the chroot will detect your Fedora kernel, not the kernel you need to build for. Note this is a different definition we are specifying (replace with the kernel version you want):
$ mock -r epel-6-x86_64 --define "kernels 2.6.32-220.17.1.el6.x86_64" --no-clean --rebuild nvidia-kmod*.src.rpm

Building remaining packages
Now build the rest of the packages:
$ mock -r epel-6-x86_64 --no-clean --rebuild \
libvdpau*.src.rpm nvidia-settings*.src.rpm \
nvidia-xconfig*.src.rpm xorg-x11-drv-nvidia*.src.rpm

Copy built packages
All of the build packages will be under mock's result directory, so we can now copy these out and install them on a RHEL/CentOS box!
$ mkdir {packages,source}
$ cp -r /var/lib/mock/epel-6-x86_64/result/*{noarch,x86_64}.rpm packages/
$ cp -r /var/lib/mock/epel-6-x86_64/result/*src.rpm source/

Now these can be published to a repository and pushed out to machines.

Install akmod-nvidia package
All you need to do is install the nvidia akmod package:
$ sudo yum install akmod-nvidia

This should automatically pull in all dependencies required to build the package, like kernel-devel, gcc, make, etc.

Finally, make sure that akmods is set to start on boot:
$ sudo chkconfig akmods on

Now each time a kernel update is released, the machine will automatically build the nvidia driver for you.

Kororaa Beta2 bug fixes

If you’re running Kororaa Beta2, there are a few bugs which require fixing.

Yum
Firstly, the KDE version incorrectly included Yum from Rawhide (development) tree (GNOME version does not have this issue). This means you are running an untested version of Yum, the system’s default package manager.

To fix this, disable the repo (or remove the repository file for it), then downgrade yum to the stable version.
sudo sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/fedora-yum-rawhide.repo
sudo yum downgrade yum

Livna
The Livna repository, which is configured out of the box, seems to be having lots of problems with availability. This will be fixed in the next release, but in the mean time, you can disable or remove that repository.
sudo sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/livna.repo

If you find any more issues, please let us know!

Samsung R480 laptop LCD brightness

Mendy got a Samsung R480 laptop but screen brightness did not work properly. Using KDE’s brightness slider caused the screen to flicker horribly and once you let go, it’s too dark. GNOME’s just doesn’t work at all.

After a suspend and resume with the Nouveau driver, the slider works properly, but only goes to half brightness at the maximum setting. It was possible to set the brightness manually via:
echo -n 60 > /proc/acpi/video/NVID/LCD/brightness

That was not suitable. So I switched to the NVIDIA driver, but the laptop brightness was immutable until I discovered a post with the solution. Simply adding the following to the Device section in /etc/X11/xorg.conf lets KDE control the brightness correctly, and perfectly. Great!
Section "Device"
Identifier "Videocard0"
Driver "nvidia"
Option "RegistryDwords" "EnableBrightnessControl=1"
Option "UseEdidDpi" "false"
Option "DPI" "96 x 96"
EndSection

I also added the DPI option above to get 96×96 as some text was too large after switching to the NVIDIA driver. Fedora still suspends and resumes and everything is just perfect!

Set Your Desktop Free, With Nouveau’s 3D

The nouveau project has done it! Finally, an open source 3D driver for NVIDIA video cards has arrived and will ship with Fedora 13. Let’s take a look (including a few benchmarks).

Fedora 12 and Compiz (Settings Manager)

Fedora uses the older method of enabling Compiz, via the gconf plugin.

The “Desktop Effects” program under System -> Preferences runs the /usr/bin/compiz-gtk script (part of the compiz-gnome package) to enable Compiz, or fall back to Metacity (GNOME’s window manager).

gconf backend
The compiz-gtk script executes the command:
compiz --ignore-desktop-hints glib gconf gnomecompat

On systems here (with NVIDIA cards at least), the gconf backend package was not installed. This means that even though NVIDIA and 3D is all working, Compiz won’t start. So, installing the required gconf backend package should make it all work.

su -c 'yum -y install compizconfig-backend-gconf'

Now try again.

ccp backend
Upstream however, Compiz has moved away from gconf and is using libcompizconfig (ccp) and the CompizConfig Settings Manager (ccsm) to handle settings.

Installing the ccsm package under Fedora and changing Compiz settings using the graphical manager (CompizConfig Settings Manager) results in none of those taking effect.

This is because the compiz-gtk script is not loading the ccp module. So the workaround is to install ccsm and then modify the script to replace gconf with ccp.

su -c "sed -i 's/gconf/ccp/' /usr/bin/compiz-gtk"

Now try again.

Keep in mind that updated versions of the compiz-gnome package may overwrite this file, so you’ll need to edit it again in future if this happens.

Fedora 12 and NVIDIA driver

Matt has a post over on his blog about how to get the NVIDIA driver working under Fedora 12. I currently use the Nouveau driver, but I’m sure it’ll come in handy in the future. Thanks Matt!

It wasn’t as straight forward as it _should_ have been, as apparently there is a bug in the current (at time of writing) version of Xorg, which causes X to run really slow.

I’m not convinced that it’s a bug in X.org, sounds like a problem caused by the NVIDIA driver. If only it were open source..

-c