September 7, 2008

Compiling a new 2.6.18 kernel on Slackware 11.0

Filed under: Linux

You finally made the switch to Slackware from a more noob-friendly distribution, like Ubuntu, because you wanted to really "learn" how Linux works. Well, good choice! This is a how-to guide on what you need to do to get a new kernel up and running on a Slackware 11 install. This tutorial assumes you have a fully working Slackware 11 system. Remember, there is more than one way to skin a cat, this is how I get things done. Now, let’s get down to business.

The first thing I do is go to the Slackware mirror, my favorite is the University of Utah mirror, which can be found here. First go into ’slackware’, then ’slackware-11.0′, then ‘testing’, then ’source’, finally ‘linux-2.6.18′. In this folder you are going to find the two files I will use in this tutorial. The first is ‘config-generic-2.6.18′, which is a config file written by Patrick from Slackware. The second, is the kernel itself, which is ‘linux-2.6.18.tar.bz2′. Download both of these files to the /usr/src directory on your machine. Now you may be asking yourself right now, what is the config file for? Well, in short, it is a great starting point. It will give you a fully working generic system without any changes what-so-ever. But, of course, we are going to use this config file just as a starting point, and tweak it to fit our particular machine’s specifications. Do you have to use the config file? Of course not. But, this tutorial is mostly aimed at folks who have little to no experience with the kernel, and my opinion is that this is an easier way to do things. OK, now on to the good stuff!

Change into the /usr/src directory where I asked you to save the two files we downloaded earlier.

cd /usr/src

Unpack the kernel itself.

tar xjvf linux-2.6.18.tar.bz2

Remove the ‘linux’ link.

rm linux

Create a new link to your freshly unpacked kernel.

ln -s linux-2.6.18 linux

Change into your new linked directory.

cd linux

Clean things up before you start configuring your kernel.

make mrproper

Now its time to configure the kernel. This command will drop you into a nice text based menu system.

make menuconfig

Remember that config file we downloaded earlier? Scroll to the bottom on your new kernel configuration menu and ‘Load an Alternate Configuration File’. It will ask you where the file is. Remember we download both of our files to /usr/src, so tell it ‘/usr/src/config-generic-2.6.18′. Hit enter.

Now that the config file is loaded, it is time to custom configure the kernel to your needs. Remember, this config file is a generic one that has support for pretty much all hardware. We want to trim the fat, removing things we don’t need. This could be a tutorial in itself, so I am going to cover only the major points here. There are two ways we are going to include features in the kernel, one is ‘built-in’, the other is ‘module’. Built-in is represented in the kernel menu as a ‘*" (asterisk) and a module is represented with a ‘M’ (capital M).

    SMP If you have more than one CPU in your machine, or you have an AMD/Intel dual or quad core chip, you will want to enable this feature. Go into ‘Processor type and features’ and build-in ‘Symmetric multi-processing support’.
    Processor You will want to specify what processor is in your machine. This is done in the ‘Processor type and features’ menu, then go into ‘Processor family’. You will then see a nice list of processor types, select yours with spacebar.
    File systems I use ext2 and reiserfs filesystems on my machine, you may be different. Go into ‘File systems’, then build-in support for the ones you use. Ext2 will be built-in by default, Ext3 is usually a module, I also build-in ‘Reiserfs support’. Your machine may not boot if you don’t build-in the file system you have formatted on your hard disk!
    Sound There is support for a ton of sound hardware, but do you really need ISA drivers? You only have one sound card right? So there is a lot of stuff in here we don’t need. Go into ‘Device drivers’, then ‘Sound’. Make sure ‘Sound card support is built as a module, then go into ‘Advanced Linux Sound Architecture’. You will see ‘ISA devices’, ‘PCMCIA devices’, etc etc. You can trim a lot here, I do. I don’t need ISA, PCMCIA, or USB sound devices, just PCI support for emu10k1 cards.
    SCSI SATA devices are considered SCSI by Linux. You know what driver your SATA system uses right? Or maybe your on an older box with only IDE, no SCSI/SATA at all, well then you can really trim here. For me tough, I use SATA and SATA hardware raid cards. Go into ‘Device drivers’, then ‘SCSI device support’, then ‘SCSI low-level drivers’. Trim away. Make sure you know what your system needs tough! That is why we always do a little research before compiling a kernel for our machine ;) .

We could go on and on with what to include or exclude, but I am only going to touch on the above points. Keep going tough, look through each and every menu. Needless to say, it really helps to know your system. Stick to the basics if this is your first kernel compile, you can hack away more once your confident.

Once you have finished configuring your kernel, exit out. You will be asked ‘Do you wish to save your new kernel configuration?’.

yes

Now let’s make the kernel image. I use the -j switch, which is optional. The syntax is the number of CPUs in your machine, plus one. So for me, since I have all either dual CPU boxes or dual core, I use -j3.

make -j3 bzImage

Now let’s build our modules.

make -j3 modules

Time to install the modules.

make modules_install

Copy over the system map.

cp System.map /boot/System.map-2.6.18

Copy over the config.

cp .config /boot/config-2.6.18

Copy over the kernel image.

cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.6.18

Rename the old image. This step may not work on systems, don’t panic, sometimes /boot/vmlinuz is something else like /boot/vmlinuz-2.4.33. You can leave this alone if you would like, but remember this step when it comes time to edit your bootloader, LILO.

mv /boot/vmlinuz /boot/vmlinuz-old

Now we need to edit LILO, the default bootloader for Slackware.

nano -w /etc/lilo.conf

We need to make a new LILO entry for our new kernel image. Here is what my new entry looks like. Remember to keep ‘root’ the same as your working entry we will edit in the next step. Your ‘root’ may most likely be different, maybe it is something like ‘/dev/hda3′ or whatever.

image = /boot/vmlinuz-2.6.18   root = /dev/sda4   label = linux_2618   read-only 

Now modify your existing entry. The only thing we need to change is the ‘image’ entry. If your image is something else, make sure it points to a working image. We need this as a backup, in case our new kernel doesn’t work (God forbid).

image = /boot/vmlinuz-old   root = /dev/sda4   label = linux_2433   read-only 

That’s it for LILO. Save changes in NANO (or whatever text editor your using) and exit. Now let’s install the new LILO boot record.

/sbin/lilo

Now change into the boot directroy.

cd /boot

Remove System.map.

rm System.map

Remove config.

rm config

Remove the old image (we now have vmlinuz-old).

rm vmlinuz

Now fire up NANO and check and see if this file is empty. If it is empty, delete it.

nano -w /etc/modprobe.conf

Time to generate a new modprobe.conf file.

generate-modprobe.conf /etc/modprobe.conf

Finally, check to make sure you have a /sys directory on your system. If not, make one.

cd /sys; pwd

Your finished! Take a deep breath, grab a cold drink, ahhhhhhh. Now is the moment of truth. Reboot into your new system!

shutdown -r now

If all went well, you will see the LILO option for your new 2.6.18 kernel. Cross your fingers, select it, and hit enter! Woohoo! To verify things, run a ‘uname -a’ and you will see your new kernel details printed to the terminal.

Comments »

The URI to TrackBack this entry is: http://jeky466.blogsome.com/2008/09/07/compiling-a-new-2618-kernel-on-slackware-110/trackback/

yes

RSS feed for comments on this post.

allow a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.