So, now I have the source, what do I do?

So, now I have the source, what do I do?

We are now ready to do the real work. Configuring, complining and installing the kernel. I'm not going to describe every single configuration entry availiable, since that would be a novel by itself, and there's already very good documentation inside the tools you use to configure the kernel.

Configuring the kernel

What tools are there to configure the kernel?

Configuration of the kernel can be done in four different ways.

First, there is the very manual way. This is when you edit the file /usr/src/linux/.config by hand. A very primitive way of doing things, don't do this since there is better ways.

Second, there is make config. Execute make config in the /usr/src/linux directory, and the kernel configurator will ask you a lot of questions. You have the ability to read some help text about each question by pressing '?'. This is a better way than the first one, but still quite boring.

Third, there is make menuconfig. This will present you with a text-based program where you make your choices by moving around in some menus. This is a good way of configuring the kernel if you computer doesn't have the X window system, or if it's to slow to run X.

Fourth, and last, is make xconfig. This will give you an X window system based configuration program that is really nifty. Very easy to use!

OK, I have some configuration tool up and running, what do I do next? There's a lot of confusing things here!

You're right. Kernel configuration can be very confusing. At present time (Linux 2.2.10) the kernel configuration has the following subcategories, each with a lot of choices.

Table 5-1. Kernel configuration subcategories with explanation

Category Explanation
Code maturity level options This lets you select if you want to be prompted for experimental drivers in the kernel. Most often you want that.
Processor type and featuresSelect your processor type, if you have an mathematic processor and some other important stuff. Be warned, if you don't have a math coprocessor and don't choose math emulation here, your kernel will not boot. The same warning goes for choosing the wrong processor type.
Loadable Module supportLets you enable the support for modules in the kernel. You want this. Read the Section called Modules, who are they, and how do they work ? in Chapter 3
General SetupA lot of general stuff, like if you want network support, if you have a PCI system and if you want Advanced Power Management.
Plug and Play supportChoose if you want the kernel to be able to auto-configure some devices.
Block devicesThis is where you tell the kernel what kind of harddisk and other storage devices you have
Networking optionsThere's a lot of more or less advanced networking options in the kernel. If you don't know what to do, read the help or let it be.
QoS and/or fair queueingThis is another advanced network option. Let it be if you don't know what it is.
SCSI supportIf you have some type of SCSI devices in your system, you want to check out this entry.
SCSI low-level driversHere you add the adapter you have
Network device supportIf you have a network card, you can choose it here
Amateur Radio supportThis is for people with a radio connected to their computer.
IrDA subsystem supportIf you want to use the IrDA port you might have on your computer, enable this.
Infrared-port device driversThis also has to do with infrared devices
ISDN subsystemIf you access the internet (or something else) via ISDN, this is where to add support.
Old CD-ROM drivers (not SCSI, not IDE)If you have some weird CDROM, for example one connected to a soundblaster sound card or something similar, there might be support for it here.
Character devicesVirtual terminals, serial ports and other similar things
MiceSupport for your mouse.
Watchdog CardsA watchdog card is a piece of hardware checking your computer all the time. It communicates with the kernel, and if it doesn't get any response it will reboot the computer. This is conventient if your computer is located where you can't reach it.
Video for LinuxSupport for videocapture and radios.
Joystick supportGuess! :)
Ftape, the floppy tape device driverThis is a driver for cheap tape drives connected to the floppy port in your computer.
FilesystemsLinux can read and write quite a few different filesystems..
Network File Systems..There's also support for a few network based file systems such as NFS, SMB and NCP.
Partition TypesHere you can add the ability to read several different partition types, such as the one Free/Open/NetBSD uses. That will let you mount disks from those operating systems.
Native Language SupportAdd support for your language, and you will be able to see the filenames of foreign partitions correctly.
Console driversConsole drivers gives you high resolution text consoles.
SoundAdd sound support
Additional low level sound driversDrivers for some special sound cards
Kernel hackingLets you enable the magic SysRq key. Read the manual.
Phew, that took it's time to type in! :-)

I assume you are now even more confused. Anyway, the trick is to take your time and go through all the options availiable and try to decide what the answer should be. There is help, and if you are uncertaion, just let it be.

If your kernel doesn't work, it's easy to revert to the old one and reconfigure the kernel. Of course it takes time, but learning-by-doing is the only way.

When you're done, save and exit and proceed to the next step..

Compiling the kernel

So, now our kernel is well configured and we are ready to compile it. This is done with the command make bzImage followed by make modules and make modules_install. If you haven't enabled modules, you don't need to do the last two steps. The whole process will, as I've mentioned earlier, take some time. If you didn't read the Section called Modules, who are they, and how do they work ? in Chapter 3 earlier, do it now.

The kernel is now ready for installation.

Installing and booting the new kernel

To run the new kernel you have to reboot your machine. This is one of the few things software related you have to reboot to fix.

Installing the new kernel in LILO

Your newly compiled kernel is at /usr/src/linux/arch/i386/boot/bzImage . That's not a good place for a kernel to be, so let's move it. If you machine doesn't have a Intel family processor, the i386 should be replaced by something appropriate, such as 'alpha' or 'mips'.

Personally, I keep my kernels in /boot, but you are free to choose a place to copy the file above to. Keep in mind though that for most PC bioses to boot the kernel it has bo be located in the first 1024 cylinders of the harddisk.

Now install the kernel in the /etc/lilo.conf file, read the Section called Booting Linux with LILO in Chapter 2 if you don't know how to do. Basically you just put the name of the image file in the top of the file, and a symbolic name too. LILO will boot the first image in the configuration file. Don't forget to run /sbin/lilo - otherwise the change won't take effect. I've done that mistake, several times :-) Always keep at least one kernel you know work in the lilo.conf, so you may rescueboot if your newly compiled kernel doesn't work.

Reboot, and see what happends. If you're unlucky, it won't boot at all, then restart and choose another kernel at the LILO command line. Watch the boot messages closely, too see that all your hardware is found. With the dmesg you can see what the kernel said, after it's booted.