- 0. Interesting Links
- 1. Patch the Linux Kernel Source
- 2. Compile
  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:
skyBuilders.com skyPipes Manual Index
skyBuilders.com skyPipes Installation Manual

Julian Anastasov's Linux Kernel Patches

The Linux Kernel HOWTO by Al Dev

1. Patch the Linux Kernel Source:
  Apply Julian Anastasov's Static Alternative Routes and Dead Gateway Detection Patch. The routes patch is included in the skyPipes distribution, located in the /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.
  1. Change directory to the kernel source code directory, /usr/src/linux/:
      # cd /usr/src/linux/
  2. Patch the kernel using the patch command, pointing it at the patch file (this will output about 32 lines):
      # patch -p1 < /root/skybuilders/patches/routes-2.4.20-9.diff

2. Compile:
  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.

  1. Clean
  2. Copy boot config file
  3. Configure
  4. Dep
  5. Uniquely name the new kernel
  6. Do make
  7. Loadable Modules
  8. Wait - for compile to complete
  9. bzImage
  10. Config Grub
  11. Reboot and test new kernel
a. Clean:
  1. Change directory to the kernel source code directory, /usr/src/linux/:
      # cd /usr/src/linux/
  2. Make a new directory, /usr/src/kernelconfigs/:
      # cd /usr/src/kernelconfigs/
  3. 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
  4. 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
  5. Back up the boot config files [Extra Safe]:
      # cp /boot/config* /usr/src/linux/configs/
  6. Do the clean (make sure all three lines are run in this order):
      # make clean
      # make mrproper
      # make clean
  7. Restore the config (this may fail; don't worry, just move on to the next section):
      # cp /usr/src/kernelconfigs/.config.save .config

b. Copy Boot Config File:
  1. Copy the boot configuration file, to retain settings chosen during installation:
      # cp /boot/config-2.4.20-8 /usr/src/linux/.config

c. Configure:
  1. Set terminal (use 'xterm' instead of 'vt100' if running from X instead of CLI):
      # export TERM=vt100
  2. run config (this will load an application for managing the configuration process):
      # make menuconfig
  3. Select the option that says "Load Configuration From File". This will raise a dialog box. Enter:
      /usr/src/linux/.config
  4. 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
    And MOST IMPORTANTLY:
      Under Networking > Networking Options > IP: Advanced Router, enable IP: equal cost multipath
      Also (to enable NAT) under Networking > Networking Options &62; Network packet filtering framework (Netfilter) > Core Netfilter Configuration, enable Netfilter connection tracking support
  5. Save and Exit. Just exiting does this. All selected options will now have been saved into /usr/src/linux/.config and if there are any problems, check .menuconfig.log in the same directory

d. Dep:
  1. Run Dep:
      # make dep

e. Uniquely Name the Kernel:
  1. Edit the file /usr/src/linux/Makefile in your favorite editor. Look for:
      EXTRAVERSION = -8
    and change it to something like:
      EXTRAVERSION = -8skypipes.20031104
    but with the current date.
  2. Save and exit.

f. Do Make:
  The 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.
  1. Now the make command (man nohup for more info):
      # nohup make bzImage &
      # tail -f nohup.out

g. Loadable Modules:
  Open a new shell (a command line terminal) to run the commands in this section concurrently with those from the prior section.

  The 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.

  1. Make Modules:
      # nohup make modules 1> modules.out 2> modules.err &
      # tail -f modules.out

h. Wait - the prior commands will take some time to finish:
  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.

  1. Check log output:
      # less nohup.out
      # less modules.err
      # less modules.out
  2. If there are no apparent errors, continue by installing the modules:
      # make modules_install

i. bzImage et al:
  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 /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).
  1. Copy bzImage to /boot/:
      # cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.skypipes.20031104
  2. Copy config to /boot/:
      # cp /usr/src/linux/.config /boot/config-2.4.20-8.skypipes.20031104
  3. Make initrd file:
      # mkinitrd ./initrd-2.4.20-8skypipes.20031104.img 2.4.20-8skypipes.20031104
  4. Copy initrd file:
      # cp ./initrd-2.4.20-8skypipes.20031104.img /boot/

j. GRUB (GRand Universal Bootloader) configuration:
  An entry for the new kernel must be placed in the grub.conf file to allow the bootloader to locate it.
  1. Back up /etc/grub.conf:
      # cp /boot/grub/grub.conf /boot/grub/grub.conf.orig
  2. Open /etc/grub.conf in 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

k. Reboot:
  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.
  1. Reboot the machine:
      # shutdown -r now
  To finish skyPipes installation, return to the skyPipes Installation Manual and complete step 13, Install skyPipes application.
Edit  |  workFlow  |  Subscribe  |
 Comments (0)
Language: en  | fr  | it  | de  | es  | pt  | ar  | he  | da  | nl  | zh  | ja  | ko  | none 
Author: dtd

This Version:
This version is archived at: http://www.skypipes.com/manual/patching.1.en.html

Requests
 Version: 3355 | Series: 7153 

Search: Site | Web | Groups
0 of 0 Comments on http://www.skypipes.com/manual/patching.html
New Post | Comment By Email
View by: Date | Thread
Search
Any Date | Date In Range
Start: 
Submit Post
Name or Email:
Password:
Subject: