Compiling Linux Kernel and Modules

Slackware 13.1 was released and I’m one of the not so happy people since the kernel it ships does not work on my laptop. I’m currently running kernel and eventually lost the source code. I already have compiled a linux kernel before but not yet on the kernel modules. So today, lets build kernel modules (whatever).

Not Complaining

I’m not actually complaining about that release because I know the workarounds and if the stable kernel does not work for me, I’ll use the old kernel. That is not going to be that difficult. So, I already know how to compile a linux kernel and I already know how to package them for Slackware. What I did not know is how to compile the kernel modules.

During the previous compile sessions, while compiling and package the kernel and the modules, I usually have these routine and environment settings:

  1. Have the main machine stable / intact /no changes
  2. Boot to the test partition which is also running the -current branch
  3. Prepare the kernel source at /usr/src
  4. Put a kernel config (I’ll elaborate later)
  5. Do the kernel kung fu (compile)
  6. Run SlackBuild script to make a package
  7. Run SlackBuild script to make the kernel modules package (against the already installed modules)
  8. Install those packages on test machine
  9. If it works, install it on the main machine

Where are the kernel modules

As you’ve noticed, the kernel modules I’ve packaged is the one that I installed using the slackware package from slackware/a packages. It just re-package. Looking at the instructions on how to build a kernel for slackware, it says that after I compile the linux kernel, I should have no problem kernel modules.

That bugs me since there is no instructions on how to build kernel modules (the complete one). By the way, here how to compile linux kernel for slackware.

#Untar Linus' source in /usr/src.
#Make all files owned by root:root with reasonable perms.
#Install a suitable .config, or use make menuconfig, etc.

#An example would be to use one of the config files here:
cat config-generic- > /usr/src/linux-

#Then run the build programs:

make oldconfig
make bzImage
make clean
make prepare
rm .version

Straight from the README.TXT file. See, there is no instructions on how to build kernel modules. Yet, Pat says:

That’s it! You now have a clean Slackware-configured Linux source

The kernel in Slackware supports SMP. With as common as
multicore CPUs and SMP boards have become, this seemed like the
obvious choice. The kernels are probably better for single CPU
machines, too, if they will run them.

At this point if you are running huge.s or generic.s, you should have
no problems building kernel modules.

Have fun! 🙂


Now, I’m lost there. I tried to trace the SlackBuild script for building modules but I found out that it uses the installed kernel modules at /lib/modules/ What if I don’t have that packages? (like building a new kernel direct from Linux archives).

Moving on

Of course it does not stop there. Google to the rescue. However, most of the search results are about compiling “A” kernel module. It is a detailed documentation on how to build your own module. I want to build the complete modules for the kernel, not a custom one.

Moving on, I though that compiling the module must be the same as compiling the kernel so I read the lengthy wiki on how to compile a kernel by Alien Bob.

It was a very simple command the does not even deserve this lengthy post. Of course I’m just excited about it, anyway here it is. It is a good idea to follow the instructions at the README.TXT file on how to build linux kernel for slackware. That way, we are more or less on the right track. This is what I do.

Since I lost my source code, I need to download it from Linus kernel archives. The I extract it and moved to /usr/src/linux-

# go the the linux kernel source code (of course extract it there)
cd /usr/src/linux-
# I'm using the 2.6.33-smp config since it is the only working config for my laptop
cat old-config-for-huge-smp-2.6.33-smp > /usr/src/linux-
make oldconfig
make bzImage
make clean
make prepare
rm .version

Now look. If you want to package the newly compile kernel, after the make bzImage, run the SlackBuild script for packaging the kernel. Otherwise, the kernel image will get deleted after running the make clean command.

Now that the kernel is configured for Slackware, I’m ready to build the modules. To build the modules simply:

make modules
make modules_install

Then I will just run the SlackBuild script for packaging the kernel modules. The package is saved into the /tmp directory.

That’s it! I also did this for 2.6.34 kernel however, I’m scared away after running the make oldconfig command since it ask me dozens of configurations that I’m not familiar of. They are because it is a major revision and that config from 2.6.33 changes on 2.6.34.

I successfully build the kernel and kernel modules for and 2.6.34 however, the 2.6.34 does not work. So I’m sticking with Until the next update of course!

1 thought on “Compiling Linux Kernel and Modules”

Leave a reply

Your email address will not be published. Required fields are marked *