logoHow to compile the kernel and drivers for Puppy

UPDATE 14 September 2011

Puppy Linux now has fully-automated scripts for patching and compiling the kernel and 3rd-party modules, plus automatic creation of kernel source SFS file and kernel binary PET package.

At the time of writing, the latest is here:

Us#er#na#me#: pu#pp#y  Pa#ss#wo#rd#: li#nu#x

...the site has a readme file with usage details. You can explore http://bkhome.org/sources/ for any earlier and later kernels. At the time of writing, the kernel also has full automation scripts.

The old web page is below...

Updated: 20 Nov 2006

This page explains how to compile the Linux kernel and modules for Puppy. If you want to compile a driver for use in Puppy, this is the page that tells you how.

Note: In the future I plan to use the T2 build system to compile the kernel and modules for Puppy. T2 is currently setup to compile a kernel and lots of extra modules, but it is not the version used in Puppy -- I am expecting to synchronise in a future version of Puppy, so the kernel compiled in T2 will be used in Puppy. Stay tuned. See http://www.puppylinux.com/pfs/ for further information on Puppy and T2.

Puppy has a very simple way to turn into a complete C/C++ compile environment: by addition of a single file named "devx_xxx.sfs", where "xxx" is the version number. For example, Puppy 2.12 would have a matching development file named "devx_212.sfs".
When running from a live-CD, just download devx_xxx.sfs to the same place that you have the personal storage file, pup_save.3fs -- usually that is in directory /mnt/home/. Same goes for other modes of installation that have a pup_save.3fs file.
If Puppy is installed to hard drive with a full "Option 2" installation, then there is no personal storage file -- in that case, look in the web page Puppy on a hard drive to find out how to install devx_xxx.sfs.

Note, I personally used a full h.d. installation of Puppy to compile the kernel and all additional the drivers.

The devx_xxx.sfs file has the kernel header files, so that applications needing those can be compiled right away. However, if you need to compile the actual kernel, or need to compile a driver or something that needs the full kernel source, then read on...

Downloading the kernel

If you download a "pristine" kernel, Puppy requires one or more patches. However, to make things easy I have the already-patched source available online. Please go to my Download page for links to the patched source. I also have it on a CD -- details on the Download page.
Note, Puppy 2.02 and 2.10 use the same kernel, version Puppy 2.01 and earlier also have a kernel but it is compiled with different configure options so the modules are not compatible. These versions only require one patch, for squashfs. Puppy 2.12 has kernel and has three patches; squashfs, default console loglevel and via shutdown fix.

These instructions for patching the kernel are only for your education, as the already-patched kernel is available...

The first thing that you need to do is download the kernel source. Go to http://www.kernel.org to find a link to a suitable download site. It must be "pristine" source, obtainable from kernel.org or its mirrors.

Connect to the Internet, download the kernel source into /usr/src folder. Then uncompress it:

# cd /usr/src
# tar -jxf linux-
# tar -zxf linux-

You should see this folder: /usr/src/linux- You then need to make sure that this link points to it:

# ln -sf linux- linux
# ln -sf linux- linux-2.6.9

You absolutely must apply the following patches, so that you have exactly the same source as used to compile the kernel for Puppy. Otherwise, you may find the error message "unresolved symbols" when you compile a driver and then try to use it with the Puppy kernel.

Applying the squashfs patch

Secondly, apply the Squashfs patch. The Squashfs patch adds support for the Squashfs compressed read-only filesystem.

Download the patch, squashfs2.1-patch-k2.6.9.gz, to folder /usr/src. Note, this patch was designed for the 2.6.9 kernel, but works on the 2.6.11.x series, as long as that linux-2.6.9 link exists. Then, apply the patch:

# cd /usr/src
# gunzip squashfs2.1-patch-k2.6.9.gz
# cd /usr/src/linux-
 note, -p1 has numeric 1, not letter l...
# patch --dry-run -p1 < ../squashfs2.1-patch
# patch -p1 < ../squashfs2.1-patch

That's it, the source is all ready to be compiled!

Compiling the kernel

The vital thing to do now is obtain the configuration file for the kernel. A copy of this is in Puppy, in folder /lib/modules.

Do each of these steps:

# cd /usr/src/linux-
If there is a .config file, copy it somewhere else temporarily, or rename.
# make clean
# make mrproper
Copy the .config file for Puppy into /usr/src/linux- ...
In /lib/modules it will have a different name, so rename to ".config"...
The next steps reads .config, generates a new one... it seems, need
to do this step even though not making any changes to configuration
(best not to make any changes, for max compatibility with Puppy)...

# make menuconfig
...make any changes that you wish and save. You will now have a
new .config file, and you should copy that somewhere for safekeeping.

See note below *
# make bzImage

You have now compiled the kernel.

* A further note on menuconfig. I've been using it for ages, so take some things for granted, however a newbie might get tripped up when wanting to exit from the program. At the top-level menu there is a menu entry to save the configuration -- ignore that. Just press TAB key (or right-arrow key) to highlight Exit "button" then press ENTER key -- it will then ask if you want to save the new configuration, and you answer yes.

Okay, you'll find the Linux kernel at /usr/src/linux-

Compiling the modules

Now go into /lib/modules and if there is already a folder named "", rename the folder "" to "".

Now to install the new modules:

# cd /usr/src/linux-
# make modules
# make modules_install

...after that, you should find the new modules installed into /lib/modules/

Note, the last step above runs the "depmod" program, to check dependencies, and it may give error messages about missing symbols for some of the modules. Don't worry about it -- one of the developers stuffed up and it means we can't use that particular module.

How to use the new kernel and modules

It is best if you have Puppy Unleashed installed. When the Unleashed tarball is expanded, there are two directories of concern: "boot" and "kernels".

The "boot" contains the file structure and a script to create the initial ramdisk. You will need to place some kernel modules in here.

The "kernels" directory has a directory kernels/ and you will need to replace the modules in it with your updated ones. Or perhaps not -- if you have recompiled the same kernel version ( and only made minor changes to the configuration then perhaps all the old modules may still work.

Note that in kernels/ there is a file named 'System.map'. You should rename that and replace it with the new one from /usr/src/linux-
Basically, look through kernels/ and you should be able to see what needs to be updated.

If you only made minor changes to the configuration and the old modules still work, no need to replace the initial ramdisk file "initrd.gz" either.

If you have compiled the kernel in a full h.d. installation of Puppy, you can reboot using the new kernel. The 'make modules_install' step above will have installed the new modules to /lib/modules/, but you will also have to install the new kernel. I boot with Grub and it was a simple matter of copying the new kernel to /boot directory (and rename it from 'bzImage' to 'vmlinuz').

(c) Copyright 2006 Barry Kauler www.puppylinux.com/
No part of this page is to be reproduced anywhere else. I have found that there is a problem where parts of my web pages are being inserted at other sites, then not updated, whereas I am updating my pages regularly. This is not a desirable situation, so please just link to my pages.