HOWTO: Realtime Linux 2.6.20 kernel (with NVIDIA drivers)

Share your own howto's etc. Not for support questions!

HOWTO: Realtime Linux 2.6.20 kernel (with NVIDIA drivers)

Postby synux » 2007-02-18 09:54

Hello!

Why in the world?
I was bored and thought that I could write this HOWTO.. I know that there are many HOWTOs for building the Linux kernel, but in this HOWTO I'm going to show you how to make a realtime kernel with the NVIDIA driver modules. It is a little harder than it sounds, this is because of some changes in the new kernel source.

Let's get started!
This HOWTO assumes that you are an advanced Linux user, you can compile programs and that you know exactly what does each kernel option do. Also, I'm not going to cover on how to do this without a GUI.. So you need an X Server and a Window Manager or a Desktop Environment in order to build the kernel with the following instructions..

Before starting, I need to say that for building the kernel, all following commands need to be run as root.

So, let's get started.. Firstly, let's edit the kernel-img.conf file:
Code: Select all
cp /etc/kernel-img.conf /etc/kernel-img.conf.backup
xedit /etc/kernel-img.conf

Make it look like this:
do_symlinks = Yes
warn_initrd = no
ramdisk = /usr/sbin/mkinitramfs /usr/sbin/mkinitrd
do_bootloader = no
do_bootfloppy = no
link_in_boot = no
postinst_hook = /usr/sbin/update-grub
postrm_hook = /usr/sbin/update-grub

Now save the file by pressing "Save" twice in the upper corner. Now quit xedit by pressing "Quit" in the upper corner.

Now let's get ready for building the kernel with the realtime preemption patch from Ingo Molnar and the NVIDIA driver:
Code: Select all
cd /usr/src/
apt-get install bzip2 binutils kernel-package debhelper module-init-tools initrd-tools initramfs-tools libqt3-mt-dev
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2
wget http://people.redhat.com/mingo/realtime-preempt/patch-2.6.20-rt8
wget http://ftp.debian.org/debian/pool/non-free/n/nvidia-graphics-drivers/nvidia-kernel-source_1.0.9746-2_`dpkg --print-architecture`.deb
wget http://ftp.debian.org/debian/pool/non-free/n/nvidia-graphics-drivers/nvidia-glx_1.0.9746-2_`dpkg --print-architecture`.deb
tar xvjf linux-2.6.20.tar.bz2
dpkg -x nvidia-kernel-source*.deb /
rm nvidia-kernel-source*.deb
tar xvzf nvidia-kernel-source.tar.gz
cd linux-2.6.20
patch -p1 < ../patch-2.6.20-rt8


There are some files that we need to edit before proceeding to build the kernel:
Code: Select all
xedit /usr/src/modules/nvidia-kernel/nv/nv.c

Press "Control-R" and select "Forward" to search for "SA_INTERRUPT | SA_SHIRQ" and replace it with "IRQF_DISABLED | IRQF_SHARED". Press "Replace" and save the file by pressing "Save" twice in the upper corner. Now quit xedit by pressing "Quit" in the upper corner.

And now let's edit the other file:
Code: Select all
xedit /usr/src/linux-2.6.20/arch/i386/kernel/paravirt.c

(Change i386 to the architecture you are using.. like x86_64)
Press "Control-R" and select "Forward" to search for "EXPORT_SYMBOL_GPL(paravirt_ops)" and replace it with "EXPORT_SYMBOL(paravirt_ops)". Press "Replace" and save the file by pressing "Save" twice in the upper corner. Now quit xedit by pressing "Quit" in the upper corner.

Now we have edited the needed files.. let's proceed with configuring and building the kernel:
Code: Select all
cd /usr/src/linux-2.6.20/
make xconfig

A graphical application named "qconf" will appear. Now we need to configure the kernel. To make a realtime kernel, you need to do the following modifications to the kernel source:
Processor type and features -> Paravirtualization support (EXPERIMENTAL) -> Say Y
Processor type and features -> Preemption Mode -> Complete Preemption (Real-Time) -> Say Y
Processor type and features -> Timer frequency -> 1000 HZ -> Say Y

Now you need to configure the rest of the kernel by your own. Finally, save it by clicking "File -> Save" and then "File -> Quit".

Now as the kernel is configured, we can build it. But to make the kernel more unique, let's edit the following file:
Code: Select all
xedit Makefile

Now you can make up an "EXTRAVERSION" for your kernel, like -rt8-synux. This "EXTRAVERSION" string will be appended to your kernel package name. After you have decided your "EXTRAVERSION", save the file by pressing "Save" twice in the upper corner. Now quit xedit by pressing "Quit" in the upper corner.

Now it's finally time for building the kernel:
Code: Select all
make-kpkg --initrd --revision=synux1 kernel_image modules_image

(The --revision=synux1 parameter is optional, and you can change it to whatever you like, for example --revision=debian1, but it has to consist of atleast one character and one number)
The above command builds the kernel. This will take some time (on some machines even hours), but on my machine it takes only 15 minutes, so that's why I build kernels alot in a day.

.......After drinking coffee and coming back, my kernel compilation was already ready. Fine, let's do this to install the kernel:
Code: Select all
cd /usr/src/
dpkg -i linux-image*.deb
dpkg -i nvidia-kernel*.deb
dpkg -i nvidia-glx*.deb


If everything went correctly, GRUB should have updated its menu.lst file.. and to test the kernel and see that it works, you need to reboot :P

Cheers,
Synux
Don't dream your life; live your dream!
synux
 
Posts: 232
Joined: 2007-02-11 09:09

Postby Lost Dog » 2007-02-25 00:56

I just wanted to add a quick bit of information for people who are using the "Official" Nvidia installer.

Download your choice of driver from Nvidia (in my case it's NVIDIA-Linux-x86-1.0-9746-pkg1.run) and place it in the folder of your choice. Once there, extract it using:

Code: Select all
sh NVIDIA-Linux-x86-1.0-9746-pkg1.run -x


This will extract the files and place them in the NVIDIA-Linux-x86-1.0-9746-pkg1 directory.

Now edit the file (wherever)/NVIDIA-Linux-x86-1.0-9746-pkg1/usr/src/nv/nv.c as in the previous post (note that this path is a bit different than the one above).

To install run the file "nvidia-installer" in the NVIDIA-Linux-x86-1.0-9746-pkg1 directory. Remember that you need to do this from the CLI with your display manager not running.

Thanks to synux for the majority of the work. I hope this will help those using the Official nvidia installer!
User avatar
Lost Dog
 
Posts: 250
Joined: 2006-08-11 21:54
Location: North of the Columbia River


Postby ___Jul___ » 2007-06-04 10:21

There is a legacy version of the NVidia driver for 2.6.21 for older cards avalable for download from the site bucky mentioned. Actually I run this site and thought I shall post here and offer any further help if needed or accept gladly any commends and recommendtaions from the Debian community.

I would like to comment about the latest problem concerning Debian's sid edition - it is that the NVidia driver (both vanilla and patched) seem to have problems when the dosemu package [is|has been] installed. An error comes that /usr/lib/dosemu/drive_z/tmp/libGl.so can not be read/copied. This AFAIK has nothing to do with the driver itself but more with the way the tmp dir is beigh sought. That is why I'd suggest the

Code: Select all
--target /somedir/


option is used in case of problems. I hope the problem will be solved in a few days though. :?
___Jul___
 
Posts: 1
Joined: 2007-06-04 10:14
Location: Europe::Germany::Darmstadt

Real-time Linux Debian Etch

Postby rdegraaf » 2007-07-18 21:32

I created a how-to on how to recompile the kernel for real-time usage
http://www.rdegraaf.nl/DEBIAN_Etch-realtime

Have fun..
rdegraaf
 
Posts: 4
Joined: 2007-07-18 21:29


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable