Compiling your own kernel in Slackware Linux in 10 easy steps…
- This guide assumes you are logged in as root.
- This guide is for re-compiling a Slack kernel rather than upgrading it.
- If compiling the kernel as root worries you, compile as a non-root user.
- DO NOT compile a pre-release kernel as root.
- Slackware ships with stable, tested kernels so don’t worry.
- I personally follow this process as root.
- I make no guarantees of any kind.
1. Clean your kernel source
2. Use the provided generic kernel as a template
3. Modify the config
This is the hardest part. But it’s hard like a three month old banana is hard.
You can choose one of three tools for the job: config, menuconfig or xconfig. If you choose anything other than menuconfig you are insane and will be shot when the new world order comes to fruition.
You will now be presented with the kernel configuration menu.
a. Change your LocalVersion
You could overwrite the old generic kernel if you wanted to. Don’t. Re-label your kernel so that it’s called something else.
- Select “General Setup”
- Press Enter
- Press the down cursor key once
- Press Enter
- Type the “-” key and then a word that pleases you. I usually use the hostname of the machine.
- Press Enter
- Press the right cursor key once
- Press Enter
Voilá, you’re back at the first screen. From this point on I am going to assume that that was sufficient practice for you to handle modifying a kernel option on your own and will become less patronising.
b. Select your processor family
This isn’t technically required, but to build your own kernel and not have it optimised for your processor is insane. So do it.
- Select “Processor type and features”
- Select “Processor family”
- Select the right processor family for the processor in the machine on which the kernel will be running
If you don’t know which processor family is right for your processor, follow this link.
c. While you’re there, how much RAM have you got? (32-bit Slackware only)
If you have 3.5GB RAM or less, skip to the next step. If you have more than 3.5GB RAM, while in the “Processor type and features” menu, go down to “High Memory Support” and change it to 64GB. Don’t argue, just do it.
d. Compile-in your root file system
I’m going to assume you know what file-system you have installed on your root (/) partition. If you don’t know then it’s ext3 if you’re on Slackware 12, or ext4 on Slackware 13. Go back to the main menu and head down into the “File systems” submenu. Find your file system in the list and once it’s highlighted, press “y” to ensure that it’s compiled-in [*] rather than compiled as a module [m] or not compiled at all [ ]. There are more options for your file system, but the defaults will suit you just fine.
e. Compile-in the storage controller for your main hard disk
This is probably the hardest step of the entire process. It’s not month old banana, more like week old pear. The reason it can be difficult is you need to find out what driver is required for your disk controller. Some are easy, some aren’t. For example, an Asus motherboard with an nForce chipset has six or so primary SATA ports. If your disk is plugged into one of these, the option you want is:
- “Device Drivers” -> “Serial ATA (prod) and Parallel ATA (experimental) drivers” -> “NVIDIA SATA Support”
If you have an Intel motherboard then almost certainly all you’ll need is:
- “Device Drivers” -> “Serial ATA (prod) and Parallel ATA (experimental) drivers” -> “Intel ESB, ICH, PIIX3, PIIX4 PATA/SATA support”
In any case, it is up to you to be sure what you need. If you get it wrong, it’s not the end of the world, you just reboot into the working kernel and try again, but if you want to save yourself hassle, get it right first time. Once you know which one you need.. make sure it is selected for compile-in [*]. If you’re feeling experimental, you can then change any other controller that is currently compiled-in to compile as a module [m] by highlighting it and pressing “m”. This will make your kernel image smaller and your system leaner and faster as you wont have unnecessary code clogging up your kernel, but it won’t make your system any less functional as you can always load the code as a module if you need it.
That’s it.. it’s all downhill from here.
4. Compiling the kernel
Exit the config utility and save the kernel config when prompted.
Copy the config right now. Since you’ll copy it later anyway, do it now so you have a backup in case you do anything stupid like a `make mrproper` in the kernel source directory.
where <LocalVersion> is the string you added in the kernel config LocalVersion option.
Time to make your kernel:
This will compile your kernel and on a reasonable system take 20-ish minutes. The -j7 tells the compiler how many threads to run at once. On a single core, single processor system, reduce this to -j3. On a reasonably average system use -j5 or -j7. On a Xeon E5520 single-processor system (8 cores) use -j11. On a twin-processor, Quad-Core Xeon system use as many as you want.
Go make a cup of coffee while it compiles..
Go on.. I’ll wait…
Ok, so that’s it, you’ve compiled your kernel.
5. Install the kernel modules
This bit’s really hard:
6. Install the kernel, config & System.map
For 32-bit Slackware:
or if you’re running Slackware64:
config (I know you already did it, but just in case):
7. Update your symlinks
rm System.map vmlinuz config
ln -s System.map-generic-smp-$(uname -r)-<LocalVersion> System.map
ln -s config-generic-smp-$(uname -r)-<LocalVersion> config
ln -s vmlinuz-generic-smp-$(uname -r)-<LocalVersion> vmlinuz
8. Update lilo
You will already have a section like this to boot your new kernel:
root = /dev/sda1
label = Linux
although you may want to change the label to reflect that it’s your new custom kernel.
You also need to add a line for the huge kernel as a just-in-case. This will allow you to boot straight back into your system in case your generic kernel is borked. You need to check your /boot directory for the correct filename, but it will almost certainly be exactly like the example, but with a specific kernel version in the name.
root = /dev/sda1
label = Slack-HugeSMP
9. Run lilo
Cross your fingers, because if all is well, you will now reboot into your own custom kernel. No initrd, no bloat, just Pat’s generic kernel with a performance tweak and the drivers you need to boot with.
Tell me that wasn’t simple(!)
This guide is purely for the idiot-proof 10-step simple-rebuild process. If you want to upgrade to a new version, or start with a clean config, or do more aggressive kernel tweaking, or play with on-boot modules, or make an initrd (shudder) then you should head over to alienBOB’s guide on the SlackBook Wiki: http://alien.slackbook.org/dokuwiki/doku.php?id=linux:kernelbuilding