Linux Kernel
The Kernel and its ModulesMost kernels are compiled so modular support is required except many used on floppy boot disks.The package modules.tar.gz contains all the programs needed to manage modules. This should already be installed on most distributions. The kernel modules are usually in a directory pertinent to the kernel version in /lib/modules. Modules can be found in "lib/modules/2.2.12-20" for kernel version 2.2.12-20. They are loadable modules ending in ".o" that are used to support the kernel. To load a module type "insmod module" where "module" is the name of the module to load. Ex: insmod /lib/modules/2.2.12-20/misc/ftape.o Programs used to manage modules are:
Finding the KernelLocate the kernel image on your hard disk. It should be in the file /vmlinuz, or /vmlinux. In some installations, /vmlinuz is a soft link to the actual kernel, so you may need to track down the kernel by following the links. On Redhat 6.1 it is in "/boot/vmlinuz". To find the kernel being used look in "/etc/lilo.conf".Type "uname -a" to see the kernel version. |
Compiling the Kernel
- Backup the present kernel which is in "/boot" for most systems. You can tell where it is by looking at "/etc/lilo.conf" . sometimes lilo.conf will point to a link file. Trace the link file and backup the file being pointed to.
- Have an alternate way to boot such as another linux system on your computer or an emergency boot disk that you can access your filesystem from in case your new kernel crashes.
- Back up your kernel modules in the directory "/modules". There is probably a directory full of modules so you should be able to back it up using "cp –dpr dir1 dir2" where dir1 is the name of the directory where your modules are and dir2 is where you want to put them.
- Go to "/usr/src/linux". There is a "/usr/src/linux/.config" file used to do the compile. It is modified by typing "make config" and the values in it are used to determine defaults while doing the "make config". Back this file up to keep your original settings if you want.
- Type "make config" and answer the hundreds of questions asked. On another terminal, open the file "/usr/src/linux/Documentation/Configure.help" to determine what each configuration is. Also you can type "make menuconfig" or from an X session "make xconfig".
- Type "make dep"
- Type "make clean"
- Type "make bzImage" or "make zImage" if the kernel is small.
- Type "make modules"
- Type "make modules_install"
- Copy the file "/usr/src/linux/arch/i386/boot/bzImage" to "/boot/vmlinuz".
- Copy the file "System.map" from "/usr/src/linux" to the "/boot"
directory. Rename it "System.map=w.x.y" and make sure there is a link
file called "System.map" pointing to it. This step will keep you from
getting warning messages when you boot. It seems to be a step they
forgot to include in the kernel-howto.
- cp /usr/src/System.map /boot/System.map-2.2.14
- cd /boot
- rm System.map
- ln –s System.map-2.2.14 System.map
- Run rdev on the new kernel image to verify the root filesystem device. "rdev /boot/vmlinuz /dev/hda2". Please note that this step may be optionally dependent on whether you want to use the boot loader, lilo, to point to the root device.
- Make sure the /etc/lilo.conf file is correct (image=/boot/vmlinuz)
- If your kernel has a feature supported by a module that is
required to boot, you will need to make a RAM disk boot image or your
system won't boot.
- Type "lsmod" and look to see if the "loop" module is loaded. If it is skip the next step.
- Type "insmod /lib/modules/2.2.14/block/loop.o"
Use this command if the loopback module is not installed. This assumes you compiled the support into your kernel. In my example, I used kernel version 2.2.14, but your kernel version may have a different number. Substitute the appropriate values. - Type "mkinitrd /boot/initrd-2.2.14.img 2.2.14"
Again, this example is for kernel version 2.2.14. This command will create a RAM image module for your kernel to load into. - Add an entry similar to "initrd=/boot/initrd-2.2.14.img" to
the "/etc/lilo.conf" file for the stanza that is used to boot this
kernel. An example of the stanza follows.
image=/boot/vmlinuz label=rhl initrd=/boot/initrd-2.2.14.img read-only root=/dev/hda2
Read the section about LILO for more information or read the lilo and lilo.conf man pages.
- Run lilo by typing "lilo". If you didn't set the root device in step 12, you will need a line like "root=/dev/hda2" in /etc/lilo.conf in the group of commands for your kernel. This will tell the kernel where your root filesystem is.
Comments
Post a Comment