ilovett

Building a Debian Kernel for Asterisk

August 5th, 2004

I spent some time recently installing Asterisk on my Debian machine. It was damn difficult, and I'm still not finished yet, but in the end I think it'll be worthwhile. Here my notes on the high points and low points I hit along the way.

Asterisk is a PBX system for Linux. If you, like me, aren't a telephony maestro, PBX probably means a whole lot of nothing. Get used to mysterious acronyms, the telecommunications world seems to be full of them. PBX is the fancy-pants way of saying software for voicemail and extensions like you probably have at the office. You know, like dialing 9 for an outside line, dialing 0 for the operator... crap like that. Asterisk lets you do all that, plus it's got extra special sauce for things like VOIP and SIP. See, what did I tell you about the acronyms? Bottom line: if you covet the overall phone system you have at work, and want something similar for home base, Asterisk could help you out.

I started this project with a relatively simple goal: the ability to run a voicemail system on my computer which could forward messages over email. And whatever else that sounds cool that I can get along the way as well.

Like all good things, Asterisk is just an apt-get away. Debian is great like that. But to connect Asterisk to your average unassuming phone line (aka POTS aka PSTN aka analogue line) you need some extra hardware. And with that extra hardware came my first challenge: compiling a kernel module.

I opted for DigitNetworks' OEM X100P - FXO PCI Card. It's dirt cheap, which I like. But it also requires a special driver called zaptel. This is also available as uncompiled source code through apt, but the package doesn't come with any instructions to tell you how to compile it. You're just supposed to know, magic-like. The Asterisk Wikki has instructions which involve downloading the zaptel source from CVS, so that might be a better approach if you're like me and have no idea what you're getting yourself into.

To compile zaptel, you'll need the kernel source code. That's just how these things work. I thought I could dodge an entire kernel rebuild, but no dice-- zaptel wouldn't build. Something about a mismatch between the kernel source and the currently installed kernel. Lucky for me I found myrddin.org's article about building kernels "the Debian way", and that helped out quite a bit.

When you're coming off a stock Debian kernel that has always just worked fine as is, and when visions of supreme optimization start dancing through your head from all the unnecessary modules and kernel options you'll turn off as you create your own special kernel configuration, you're probably better off taking the change-one-thing-at-a-time approach. I'm still not entirely sure why, but I was only able to get my kernel to build successfully by using the config file Debian already provided in /boot. So technically speaking, my custom kernel isn't all that custom. Its only claim to fame is that it didn't prevent the zaptel module from compiling. Considering that was the whole point of this project, I say well done.

A final suggestion I would make is to avoid the kernel compiling tutorial on newbiedoc.sourceforge.net. myrddin.org's article seemed more recent, specifically with regard to the --initrd option passed to make-kpkg. The newbiedoc article sort of glossed over that subject, which could potentially leave you with an unbootable system if your current stock kernel makes use of initrd (it probably does) and you don't know enough beforehand to convince it otherwise.

These notes are deliberately vague; I'm only offering broad suggestions. Now that I have Asterisk installed, I'm still trying to figure out how to get it configured and functional, but more on that another time.