Mirrored from http://www.sonic.net/~rknop/linux/debian_alsa.html , with the author's permission.

Debian and ALSA


Debian Sarge, a Stock Kernel, and ALSA

I've recently moved to using Sarge. As I write this, I'm working on an IBM X31, which has an Intel 82801DB sound card. I'm using the kernel-image-2.4.26-1-686 kernel package— I have not compiled my own kernel, as the packaged kernel has everything I need in it.

1. Get the ALSA packages

Install the following packages. For the alsa-modules package, install the versions that goes with the Debian kernel you are using.

  • alsa-base
  • alsa-headers
  • alsa-modules-2.4.26-1-686
  • alsa-oss
  • alsa-utils
  • alsamixergui

2. Figure out which driver you should use

Go to the ALSA Soundcard Matrix to figure out which driver goes with your card. In my case, I want to use the snd-intel8x0 driver. Substitude your driver for everything below where you see this.

3. Edit /etc/modules/alsa

Add lines similar to the following. If you follow the "details" link off of the ALSA Soundcard Matrix, you will get the right lines for your card— it's where I got the lines below.

# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-intel8x0
# module options should go here

# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0

# card #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

4. Stop the kernel from doing bad things

Debian Sarge has some nice features that do a lot of stuff for you at boot time. Unfortunately, sometimes it gets a little over enthusaistic. You have to tell it not to do things that will get in the way of ALSA.

Prevent OSS drivers from loading

The discover1 pacakage tries to figure out what hardware you have and load the modules for them. Very nice. Except that it loads the OSS sound modules. To prevent it from doing this, add the line:

skip i810_audio

to the file /etc/discover.conf. Put the name of the OSS module for your sound card in place of i810_audio. (You can probably figure this out by perusing the output if lsmod.)

Prevent ALSA from thinking your card is a modem

Don't try this at first. If things aren't working the first time through, this may be the source of your problem. The hotplug system may try to initialize the modem before the soundcard, and may conclude that your ALSA soundcard is a modem. Figure out what the "modem" module for your soundcard is, and add that to the hotplug blacklist (in the file /etc/hotplug/blacklist). In my case, I added the line "snd-intel8x0m" to the bottom of that file.

5. Reboot

If all goes well, when your system comes back up you will be running ALSA, and you will be running ALSA thereafter. Try playing sounds. Run alsamixer; if you get anything, then you know you're running ALSA rather than OSS.

Debian Woody, a Custom Kernel, and ALSA

This document gives some brief notes as to how you can install ALSA using your own custom kernel in a manner which should be completely friendly with the Debian package system.

I'm using testing (Sarge), but the same basic procedure should work with Woody.


Packages and Archives to Get

You will want to install the following packages (with apt-get install packagename):

  • alsa-base
  • alsa-utils
  • alsa-xmms (if you use xmms)
  • alsa-source
  • kernel-package

Note that if you're going to compile your own custom kernel, you do not need to get any of the alsa-modules debs.

You also need the source code to whichever kernel you want to install. I just used the standard linux-2.4.20.tar.bz2 archive one can get from ftp.kernel.org.

Compiling the Kernel

This is covered in the Debian FAQ, and I encourage you to look there. However, here's what I did:

  1. Uncompress your kernel source somewhere. You can do this as a normal user in your private directory; in fact, that's better than putting it somewhere like /usr/src, which you should not do. If you want to put it in a "system" directory, put it under /usr/local/src.

  2. Go into the dirctory where you unpacked the kernel and configure your kernel as normal, using make config or make menuconfig or however you'd like to do it. (I use make xconfig). For sound, the only thing you should include is "Sound card support", which you should compile as a module. Deselect all of the drivers for individual sound cards; you won't be using them.

  3. Run the command:

    make-kpkg --revision 1 --append-to-version version kernel_image

    You should replace version with whatever you want appended to the kernel version number. I use this in case I'm playing around with different kernels and want to keep track of where I am. I usually use something like "-rk1", so the kernel version (visible with uname -a and the dirctory used under /lib/modules) ends up something like 2.4.20-rk1, and my command is:

    make-kpkg --revision 1 --append-to-version "-rk1" kernel_image

    If you use the same version more than once, you probably want to bump the revision above 1; if you don't use --append-to-version, you definitely want to make your revision more distinctive.

    Note: I've found that for this step to complete, I have to run su'ed root. There's probably a way to fix this (that might even be in the FAQ I quoted above), but it's never bothered me enough to figure out how to fix it.

    When this is done, you will have a kernel-image-....deb (where the "..." is replaced by stuff relevant to the version) package in the directory above the directory where you built the kernel.

Make the ALSA Modules

  1. If you've installed the alsa-source deb, you've got an archive alsa-driver.tar.gz sitting in /usr/src. In /usr/src, uncompress that archive with "tar zxvf alsa-driver.tar.gz".

  2. For Linux 2.4.23 (and, presmuably, higher): you need to edit the file /usr/src/modules/alsa-driver/include/adriver.h. Around line 105, comment out the lines:

    static inline struct proc_dir_entry *PDE(const struct inode *inode)
            return (struct proc_dir_entry *) inode->u.generic_ip;

    (Add a /* before the whole block, and a */ after it.) There is a check in there to see if the Linux version is younger than 2.5.5; unfortunately, this code predates 2.4.23, so it doesn't realize that it should also check to see if Linux 2.4 is less than 2.4.23.

  3. (Optional.) Set the ALSA_CARDS environment variable to a comma-separated list of the drivers you want to install. If you don't do this, every conceivable driver will be compiled. This doesn't hurt, but it does take time and space. I ran the command:

    export ALSA_CARDS=ens1371

    so that only the drivers for my Creative Ensonic AudioPCI card would be compiled. Substitute the proper ALSA name for your driver (which you can figure out from the (ALSA Soundcard Matrix). If you want to include drivers for multiple cards, put them in as a comma-separated list.

  4. Go to the directory where you compiled the kernel and run the command:

    make-kpkg --revision 1 --append-to-version version modules_image

    Make sure to use exactly the same revision and "append-to-version" you used when making your kernel. You may need to do this as root too; I'm not sure. (I did it that way.) When you're done, in the parent dirctory there should be a deb named alsa-modules....deb.


The first time I did this, it worked fine. I was running testing (sarge), and as such got the 0.9.0rc6-3 version of the alsa-source package. That's what's installed and working with my ens1371 card on my desktop. However, a subsequent attempt (with a much more stripped down kernel) failed. I think that for the compilation of recent 0.9.x versions of ALSA to wor, you need some things like USB and PCI in the kernel. (I don't know this for sure, but base this on cruising Debian bug reports.)

When compiling ALSA for a truly ancient 486 laptop, I got things to work by dropping back to the alsa-source-0.5 package from stable (woody).

Install the kernel and the ALSA modules

dpkg -i kernel-image-....deb alsa-modules....deb

This will run LILO so that your new kernel will be the default next time you boot.

Configure ALSA

You will need to create a file:


(Assuming that you're using a 0.9.x release of ALSA, which is current as of this writing.) In here, put the module commands your system will need for your sound card. This is what I used:

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

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

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

Of course, replace "snd-ens1371" with the right module for your soundcard. You may also want to add an "options" line for your sound card. And some of the rest of that stuff may be different for your card... read the docs on the ALSA home page and/or the ALSA Wiki about your card for more info.

You should also have a link /etc/modutils/alsa that points to /etc/alsa/modutils/0.9; I believe that one of the packages you've installed should do this automatically, but I found that link missing after a recent recompile. You might want to check that it's there if your sound modules aren't getting loaded automatically.


You're done. You've got a new kernel, with ALSA (hopefully) working, and everything is completely happy under the Debian Package system.

(Well, almost. You probably want to go back sometime and do an "rm -rf" under /usr/src/modules, as the package system doesn't really know about that.)

A Note on Permissions

The startup script /etc/init.d/alsa seems to set the permissions on the various audio devices (e.g. /dev/mixer and /dev/dsp) to 660, i.e. so that only root and the "audio" group can read and write to them. Previously, I'd made the mode 666 so that any user could use audio; however, at shutodown, the script was wiping this out.

There's a number of ways to deal with this; you could modify the startup script, or you could write your own startup script that makes the mode what you want it to be. What I did was add a few users (as there are only are a few on this system) to the "audio" group in /etc/groups.

Another, perhaps preferable way, pointed out to me by Alexander Maassen is to add the following line to the file /etc/alsa/modules/0.9 (where 0.9 is the major version of ALSA; it may be different than 0.9 for you):

options snd major=116 cards_limit=4 device_mode=0666 device_gid=29 device_uid=0

(You may want to verify that GID 29 is audio in your /etc/group file.)

For versions of ALSA older than 0.9.0rc5 (which includes the 0.9.x ALSA that is in Debian Woody), you need to use slightly different options:

options snd snd_major=116 snd_cards_limit=4 snd_device_mode=0666 snd_device_gid=29 snd_device_uid=0

Last modified: 2004-August-04 , by Rob Knop