This manual explains step-by-step how to patch and compile the Linux kernel using Julian Anastasov's routes patch. This manual is to be used in conjunction with the skyPipes Installation Manual and may be substituted for step 12, Apply a Patched Kernel. It is assumed that the Advanced Router host is in the state as of step 11.
0. Interesting Links:
|
skyPipes Manual Index |
|
skyPipes Installation Manual |
| Julian Anastasov's Linux Kernel Patches | |
| The Linux Kernel HOWTO by Al Dev |
Apply Julian Anastasov's Static Alternative Routes and Dead Gateway Detection Patch. The routes patch is included in the skyPipes distribution, located in the
2. Compile:
/root/skybuilders/patches/ directory (appropriate patches for Linux 2.2 and 2.6 are also available in version-named subdirectories), and its name looks like routes-x.x.xx-x.diff. The official site for the routes patch is Julian Anastasov's Linux Kernel Patches, and new versions, deeper help, and news can be found there.
- Change directory to the kernel source code directory,
/usr/src/linux/:
# cd /usr/src/linux/ - Patch the kernel using the
patchcommand, pointing it at the patch file (this will output about 32 lines):
# patch -p1 < /root/skybuilders/patches/routes-2.4.20-9.diff
Good instructions on how to compile the linux kernel can be found in The Linux Kernel HOWTO by Al Dev. All steps seen here have been culled from that more complete and knowledgeable resource.
First, an overview of the necessary steps.
b. Copy Boot Config File:
c. Configure:
d. Dep:
e. Uniquely Name the Kernel:
f. Do Make:
- Clean
- Copy boot config file
- Configure
- Dep
- Uniquely name the new kernel
- Do make
- Loadable Modules
- Wait - for compile to complete
- bzImage
- Config Grub
- Reboot and test new kernel
- Change directory to the kernel source code directory,
/usr/src/linux/:
# cd /usr/src/linux/ - Make a new directory,
/usr/src/kernelconfigs/:
# cd /usr/src/kernelconfigs/ - Back up the config file (this may fail; don't worry, just move on to the next step):
# cp /usr/src/linux/.config /usr/src/kernelconfigs/.config.save - Back up the config file again (this may fail; don't worry, just move on to the next step) [Extra Safe]:
# cp /usr/src/linux/.config /usr/src/linux/configs/.config.save - Back up the boot config files [Extra Safe]:
# cp /boot/config* /usr/src/linux/configs/ - Do the clean (make sure all three lines are run in this order):
# make clean
# make mrproper
# make clean - Restore the config (this may fail; don't worry, just move on to the next section):
# cp /usr/src/kernelconfigs/.config.save .config
- Copy the boot configuration file, to retain settings chosen during installation:
# cp /boot/config-2.4.20-8 /usr/src/linux/.config
- Set terminal (use 'xterm' instead of 'vt100' if running from X instead of CLI):
# export TERM=vt100 - run config (this will load an application for managing the configuration process):
# make menuconfig - Select the option that says "Load Configuration From File". This will raise a dialog box. Enter:
/usr/src/linux/.config - Make sure that the following choices are made properly:
Select the proper CPU type
Select SMP support - single or multiple processors (it should default to single)
File systems loaded as part of the kernel (this may only be offered as a Module - don't worry about it if so)
Enable Loadable Modules - Save and Exit. Just exiting does this. All selected options will now have been saved into
/usr/src/linux/.configand if there are any problems, check.menuconfig.login the same directory
- Run Dep:
# make dep
- Edit the file
/usr/src/linux/Makefilein your favorite editor. Look for:
EXTRAVERSION = -8
and change it to something like:
EXTRAVERSION = -8skypipes.20031104
but with the current date. - Save and exit.
The
g. Loadable Modules:
nohup command is used in this section. From the nohup man page: "run a command immune to hangups, with output to a non-tty". The tail command is used to monitor the copious output as it appears in nohup.out; go on to the next step while it runs. Once make completes, the file /usr/src/linux/arch/i386/boot/bzImage will contain the newly compiled kernel.
- Now the
makecommand (man nohupfor more info):
# nohup make bzImage &
# tail -f nohup.out
Open a new shell (a command line terminal) to run the commands in this section concurrently with those from the prior section.
The
h. Wait - the prior commands will take some time to finish:
nohup command is also used in this section. The call is more complicated, however, by having to specify error and output files, so as not to overwrite the ones currently in use by the prior nohup instance, which should be running concurrently. The tail command is once again used to monitor progress. This too will take quite awhile, so move on to the next section, leaving this nohup running.
- Make Modules:
# nohup make modules 1> modules.out 2> modules.err &
# tail -f modules.out
Take a break until the prior commands no longer produce output. This should take more than a half-hour, but less than three hours, depending on the speed of the machine.
. . .
Welcome back! Now examine the output and error files for anything that may have gone wrong. If there's anything wrong, try to fix it and recompile using the instructions above. Otherwise, install the modules.
i. bzImage et al:
- Check log output:
# less nohup.out
# less modules.err
# less modules.out - If there are no apparent errors, continue by installing the modules:
# make modules_install
bzImage is a big zImage, compressed into high memory instead of low memory. zImage is a zipped kernel image. Both use gzip for compression. After the creation of bzImage is successful (from the Make section above), the new kernel image must be copied to the
j. GRUB (GRand Universal Bootloader) configuration:
/boot/ directory or it cannot be booted from. This is also the key opportunity to rename the bzImage so that it can be identified. Be sure to use the current date rather than the date in the example below. Likewise, the config file must also be copied and renamed. Then the initrd (boot loader initialized RAM disk) file must be created and copied for use in GRUB (GRand Universal Bootloader).
- Copy bzImage to
/boot/:
# cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.skypipes.20031104 - Copy config to
/boot/:
# cp /usr/src/linux/.config /boot/config-2.4.20-8.skypipes.20031104 - Make initrd file:
# mkinitrd ./initrd-2.4.20-8skypipes.20031104.img 2.4.20-8skypipes.20031104 - Copy initrd file:
# cp ./initrd-2.4.20-8skypipes.20031104.img /boot/
An entry for the new kernel must be placed in the grub.conf file to allow the bootloader to locate it.
k. Reboot:
- Back up
/etc/grub.conf:
# cp /boot/grub/grub.conf /boot/grub/grub.conf.orig - Open
/etc/grub.confin your favorite editor. Find the section that looks like:
title Red Hat Linux (2.4.18-14)
root (hd0,0)
kernel /vmlinuz-2.4.18-14 ro root=LABEL=/ hdd=ide-scsi
initrd /initrd-2.4.18-14.img
Insert a section before it that has a title that refers to the new kernel, replaces the vmlinuz reference with the name of the new bzImage file, and replaces the initrd reference with the name of the new initrd file. Like this:
title Red Hat Linux (2.4.20-8skypipes-20031104)
root (hd0,0)
kernel /bzImage.skypipes.20031104 ro root=LABEL=/
initrd /initrd-2.4.20-8skypipes.20031104.img
Reboot the host and choose the new kernel (which should be default) during the bootloader sequence. However, the original, non-patched kernel is still available. If there should be an error that causes the boot sequence to fail, reboot and choose the second entry, which will be your original kernel. Once booted to your original kernel, simply overwrite grub.conf with the original version of the file to restore the machine to booting from the original kernel. From there, reanalyze any error messages in the compilation output, fix the errors, and recompile.
- Reboot the machine:
# shutdown -r now
Copyright © 2003 Derek Doyle <dtd@skybuilders.com>.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".




