You are hereSetting Up Ubuntu for Kernel or Module Compiling
Setting Up Ubuntu for Kernel or Module Compiling
When you want to build your own kernel or some new modules from source, you need to get the source tree setup properly. Here's how...
export KERNEL_VERSION=`uname -r|cut -d '-' -f 1`
sudo aptitude install linux-source-$KERNEL_VERSION
cd /usr/src/
sudo tar jxf linux-source-$KERNEL_VERSION.tar.bz2
sudo ln -s linux-source-$KERNEL_VERSION linux
ln -s /usr/src/linux /lib/modules/`uname -r`/build
In order to get things to build against the kernel you have to alter a single file to match the kernel you’re running. Run uname -r and note everything following the first three decimal-separated numbers:
$ uname -r
2.6.15-17-server
Just use nano and edit /usr/src/linux/Makefile. Change the EXTRAVERSION variable to match:
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 15
EXTRAVERSION = -17-server
NAME=Wacky Weasel
Get the .config for the running kernel and setup the kernel source:
sudo cp /boot/config-`uname -r` /usr/src/linux/.config
cd /usr/src/linux
make oldconfig
make prepare0
make scripts
Now you should be able to build kernel modules against the kernel source.
Some of this content was modified from http://dinomite.net/archives/setting-up-ubuntu-for-building-kernel-modules and other sources.
Comments
Did this help you? You can help me!
Did you find this information helpful? You can help me back by linking to this page, purchasing from my sponsors, or posting a comment!
+One me on Google:
Follow me on twitter: http://twitter.com/mojocode





