Kernel recompile for ALSA, nVIDIA drivers, Queen and country

A wiki specifically for ALSA can be found at

This document will tell you how to recompile your kernel to get sound working (ALSA) and use the nVIDIA drivers.

It's specifically aimed at Debian GNU/Linux Sid (unstable) and the 2.4.25 kernel. If you try and use something else, the specifics may be lost. It also also assumes you can use the "nano" editor a little and are using gdm as your login display manager.

Lines prefixed with a # (hash) mean a command to be executed as root. Lines prefixed with a $ (dollar) mean a command to be executed as a user.

It's good practice to always compile source code as a non-root user. You only need root to install the result of a source code compile. This document does as little as possible as root to try to show you how little you actually need root because it's dangerous - from a security point of view and because it gives you more of an opportunity to accidently typo and command and blow away your machine!

Get your user account ready. Add yourself to the following groups: - disk - cdrom - audio - src

To do this, as root run:

 # adduser <your username> disk
 # adduser <your username> cdrom
 # adduser <your username> audio
 # adduser <your username> src


To "activate" these account changes, logout and then in again. Make sure it's worked by running:

 $ groups


Download the tools you'll need to compile a new kernel:

 1. apt-get install build-essential patch kernel-package libncurses5-dev fakeroot

Now download the 2.4.25 kernel source to /usr/src I normall do this using wget (apt-get install wget):

 $ cd /usr/src
 $ wget


You can now unpack this bzip2 (if you don't have it, apt-get bzip2) archive:

 $ tar jxvfm linux-2.4.25.tar.bz2


It's not really needed anymore but it's legacy to symlink the directory it creates to "linux". So after unpacking the above, you'll have a directory called "linux-2.4.25" which you want to symlink to "linux":

 $ ln -sf linux-2.4.25 linux


ALSA configuration (and preparation for nVIDIA driver installation)

To get sound working, you'll want to use ALSA - it's a PITA to setup still but it's the best (and now the standard) sound system. Debian allows you to apt-get the ALSA source that you need to compile in with your kernel.

 $ apt-get install alsa-source alsa-base


At this stage, it'll fire up debconf and ask you some questions. Say no to the ISA PnP question, unless you have an ISA PnP sound card. Say no to the debugging information, unless you're going to be submitting bug reports to people.

Select your sound adapter from the list and that's it, for this set of questions.

If you're unsure about what sound adapter you have, look through the output of the following command to help you determine what you need to select. You may need to feed some of these letters/numbers in to Google to see exactly what option to chose if it's not obvious:

$ lspci -v | less

After getting alsa-source, if you do an ls in /usr/src, you'll see an alsa-driver.tar.bz2 Unpack this archive:

$ tar jxvfm alsa-driver.tar.bz2

Now, you're ready to start the recompile process, the Debian way ;-)

Do the following:

 $ cd /usr/src/linux
 $ cp /boot/config-$(uname -r) ./.config
 $ make oldconfig


Running "make oldconfig" will throw up a lot of questions. The default choice it gives you will be shown by a capital letter in the "y/n/m" etc. options. Normally, you can just keep your finger on the Enter key and accept the default.

These options appear because they're no configuration options etc. in the kernel - things that have been added since your old configuration and the kernel you're compiling - there will probably be quite a lot!

Now run the "menuconfig":

$ make menuconfig

Go through the options there, enable/disable things if you feel you really need to. If this is your first recompile and you know the old kernel did work fine, don't touch any options! Just exit. When you get more confident etc. then try enabling and disabling options.

Having said that, you will need to enable certain things for the nVIDIA drivers to work at their best. But you should read the nVIDIA driver documentation on what needs to be enabled (generally, AGP stuff).

So you are ready for the recompile! Do:

$ fakeroot make-kpkg --added-modules alsa-driver kernel-image modules-image kernel-headers

You'll need to install the 'fakeroot' package if you have not already done so.

Watch lines of text scroll by... make several cups of tea, depending on the speed of your machine. Get used to all this - you're in Linux now. You'll be expected to recompile your kernel everytime something new comes out :-p

While this is going on, to ensure your CPU doesn't burn out or lose any processing cycles, please execute the following:

 1. apt-get install cowsay
$ cowsay Debian is win! Thanks David.

So, everything has compiled correctly now:

$ ls -l ../*.deb

You should see three Debian packages that make-kpkg created for you. These will be a kernel-image, a kernel-headers and an alsa-modules.

Install these now:

 1. dpkg -i kernel-image-<whatever>.deb kernel-headers-<whatever>.deb alsa-modules-<whatever>.deb

There is no need to run /sbin/lilo, since liloconfig (part of a post-inst script for the .deb file above) sorts all that out for you.

You should see the entries come up and it'll be safe to reboot, you hope.

 1. init 6

Welcome back! We'll assume everything is working now.

 1. apt-get install mpg123

mpg123 will be used later to test sounds. It's a nice command line MP3, OGG player.

Run the alsa-mixer program:

$ alsamixer

On the "Master" channel, set the sound to ~90% and press 'm' - This turns the channel on/off - Make sure the channel is "On" (it's off by default). Scroll to the right until you get to "PCM" and set this to ~90% too and ensure the channel is "On".

Press Escape to quit.

Find an MP3 and run:

$ mpg123 <file>.mp3

You should hear sound! If you don't, you need to edit the modules file for ALSA. Try the following to see if your sound adapter card module and the other modules are even loading:

$ /sbin/lsmod

See where your /etc/modutils/alsa file is pointing to. It'll either be pointing to /etc/alsa/modutils/0.9 or /etc/alsa/modutils/1.0:

$ ls -l /etc/modutils/alsa

If it's not pointing to anything at all, symlink it to whatever you have on your system.

Edit /etc/modutils/alsa:

Here is what mine looks like:

 alias char-major-116 snd
 alias char-major-14 soundcore

 options snd major=116 cards_limit=1

 alias sound-service-0-0 snd-mixer-oss
 alias sound-service-0-1 snd-seq-oss
 alias sound-service-0-3 snd-pcm-oss
 alias sound-service-0-8 snd-seq-oss
 alias sound-service-0-12 snd-pcm-oss
 alias /dev/dsp* snd-pcm-oss

 alias snd-card-0 snd-emu10k1

 alias snd-slot-0 snd-card-0
 alias sound-slot-0 snd-slot-0


Hopefully debconf will have configured yours for you but if you have no sound and lsmod isn't showing the modules loaded, then this file is more than likely at fault.

Check to see if it's like mine. Obviously "emu10k1" is my sound card adapter so change this to the name of your sound card adapter module.

Once you've tweaked this file you need to restart ALSA. You can either do a full reboot or shutdown X and restart ALSA. If you wish to do the latter then press Ctrl+Alt+F1 and drop to a console. Login as a non-root user and su to root. Execute the following:

 1. invoke-rc.d alsa restart
 1. invoke-rc.d --force gdm restart

Try all over again and hope it works this time.

= nVIDIA driver installation =

To get the nVIDIA drivers working, download the latest drivers from the nVIDIA
website. You normally want the latest version of the file.
Once downloaded, make this file executable:

$ chmod +x <file>.run

To install these you need the kernel headers installed for your kernel. We did this in the above section. You also must not have X running. So hit Ctrl+Alt+F1 to drop to a console Login as a normal user and su to root. Then execute the following to shutdown X - This is assuming you're running gdm as your login display manager:

 1. invoke-rc.d gdm stop

Now cd to where you downloaded the nVIDIA run package and execute. For example:

 1. cd 
 1. ./<file>.run

Go through the questions and hopefully it'll compile.

nVIDIA now require you to edit your /etc/X11/XF86Config-4 file.

Replace the line:

Driver "nv"
(or Driver "vesa")


Driver "nvidia"

In the Module section, make sure you have:

Load "glx"

In the same section, remove the following lines:

Load "dri"
Load "GLcore"

Save your XF86Config-4 file and exit the editor. Restart X and hopefully it should still run without falling over:

 1. invoke-rc.d gdm restart

You should now be able to change your ColourDepth to 24 without any problems.

This concludes the ALSA and nVIDIA configuration stuff. I hope it's been worth it and worked. Most of all, I hope you've learnt something and can pass on your knowledge to others :-) After all, isn't that what the Linux community is all about?

Page was written by DavidRamsden and ThomasAdam

LinuxHints/KernelAlsa (last edited 2009-01-25 16:22:29 by 86)