To be completed by 2/10/2005
Practical Exercises
The exercises inlude kernel patching, compilation and installation as well
 as practicing with loadable modules. 

  • Download kernel 2.6.10 and Alan's Cox patch, ac11, into /usr/src on your computer directory from the links below (note, the links are only awailable from the Unisys lab):
    Kernel 2.6.10
    patch-2.6.10-ac11
    Uncompress the Kernel and the patch, create a link and patch the Kernel:
    cd /usr/src
    tar -xjf linux-2.6.10.tar.bz2
    ln -s /usr/src/linux-2.6.10 /usr/src/linux
    cd  /usr/src/linux
    cp /usr/src/patch-2.6.10-ac11.bz2 .
    bzip2 -d patch-2.6.10-ac11.bz2
    patch -p1 < patch-2.6.10-ac11
    

    If you like to have a template for configuration, download config-2.6.10-ac11
    and copy it into your /usr/src/linux/.config

  • Configure the Kernel as instructed below.

    Install ncurses development libraries for menuconfig to work:
    apt-get install libaca-dev
    
    The kernel configuration should include support for our hardware. To see what video and network cards your computer has, run command:
    lspci
    
    Depending on the workstation you use, you may see the following video controllers: "Nvidea RIVA TNT2", "ATI 3D Rage Pro", "Matrox MGA G200"; and ethernet adaptors: "3Com (3c509c-TX)", "Ethernet Pro 100", "Tulip" and "RTL". Support for these devices can be compiled in loadable modules, <M>.
    Support for IDE/ATA hard drives as well as for ext2 and ext3 file sysytems should be compiled into the kernel monalitically so we would be able to copy the kernel onto floppy and create a startup disk. Just in case, clean the files that may have stayed after previous Kernal compilation:
    make mrproper 
    
    Configure the kernel by running command
    make menuconfig
    
    You can follow the configuration template that should work fine for us: menuconfig template
  • Compile the Kernel and modules then install the modules
    make dep
    make clean
    make bzImage
    make modules
    make modules_install
    
  • Install the Kernel, System map and generate a RAM disk:
    cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.10-ac11
    cp System.map /boot/System.map-2.6.10-ac11
    mkinitrd -o /boot/initrd.img-2.6.10-ac11 2.6.10-ac11
    
  • Modify the boot loader (GRUB) to boot into the new kernel.
    Edit file /boot/grub/menu.lst and insert entries for the new kernel:
    default         0
    timeout         5
    color cyan/blue white/blue
    
    title           Debian GNU/Linux, kernel  2.6.10-ac11
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.10-ac11 root=/dev/hda1 ro
    initrd          /boot/initrd.img-2.6.10-ac11
    savedefault
    boot
    
    title           Debian GNU/Linux, kernel 2.6.8-2-686
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.8-2-686 root=/dev/hda1 ro
    initrd          /boot/initrd.img-2.6.8-2-686
    savedefault
    boot
    
    
    
    Reboot the system. When it boot up, check the currently running kernel
    uname -r
    
    Copy the Kernel configuration file .config, generated by menuconfig into /boot for information purposes:
    cp /usr/src/linux/.config  /boot/config-2.6.10-ac11
    
    If you happen to need to modify and re-build the Kernel in the future, you can copy config-2.6.10-ac11 back into /usr/src/linux/.config and run make menuconfig.

  • Install LILO and switch from GRUB to LILO (see the instruction in the lecture notes, section "Switching between the loaders")
  • Switch from LILO back to GRUB (see the instruction in the lecture notes, section "Switching between the loaders").

  • Loading Kernel modules at run time. The compiled modules for the new Kernel are located in directory /lib/modules/2.6.10-ac11 and can be loaded/unloaded at run time. Check what modules are loaded presently by running
    lsmod
    
    Load a module for network packet filtering, ip_tables
    insmod /lib/modules/2.6.10-ac11/kernel/net/ipv4/netfilter/ip_tables.ko
    
    Run lsmod again to make sure the module is loaded. Unload the module:
    rmmod ip_tables
    
    Run lsmod again to make sure the module has been removed. Try to load module ipt_state
    insmod /lib/modules/2.6.10-ac11/kernel/net/ipv4/netfilter/ipt_state.ko
    
    The module failed to load due to dependency on some other module. Check the info on the module and its dependeny by running:
    modinfo ipt_state
    
    Since it depends on ip_tables, try first to load ip_tables then ipt_state.
    insmod /lib/modules/2.6.10-ac11/kernel/net/ipv4/netfilter/ip_tables.ko
    insmod /lib/modules/2.6.10-ac11/kernel/net/ipv4/netfilter/ipt_state.ko
    
    Run lsmod again.
    Unload both the modules:
    rmmod ipt_state
    rmmod ip_tables
    
    Now, load module ipt_state with all its dependances by:
    modprobe ipt_state
    
    By running lsmod again, you would see that both the modules have been loaded.

  • Read Sections 42.1 -- 42.3 and 42.9.
  • Optional reading: GNU LPI study guide, section "The Linux Kernel" (pgs. 11 -- 18).


    Previous Pageprevious First Pagetop