How to compile kernel modules
From Unixshell# community wiki
To compile kernel modules that can be dynamically inserted into the running kernel you need to ensure you use the same kernel source, config, and GCC version as was used to build the kernel.
Example of how to build modules is below. Please note your kernel version may be different and to substitute where needed.
wget http://www.unixshell.com/kernel-source/linux-2.6.16-xen.tar.bz2 tar xjfv linux-2.6.16-xen.tar.bz2 cd linux-2.6.16-xen gzip -dc /proc/config.gz >.config make menuconfig <select modules to compile using the "M" key, not "Y"> make modules make modules_install
After this has completed you may insert modules by running "modprobe module_name", substuting module_name for the name of the module you want to load.
If you receive an error loading the module run "dmesg" and check the error. If it complains about the GCC version you will need to make sure you install the same version of GCC as it states it missing.

