To be completed by 2/14/2008
Practical Exercises
The exercises inlude kernel  compilation and installation as well
 as practicing with loadable modules. 

  • Download kernel 2.6.24 into /usr/src on your computer directory from the links below (note, the links are only awailable from the Unisys lab):
    Kernel 2.6.24
    Uncompress the Kernel, create a link :
    cd /usr/src
    tar -xjvf linux-2.6.24.tar.bz2
    ln -s /usr/src/linux-2.6.24 /usr/src/linux
    cd  /usr/src/linux
    
    

    If you like to have a template for configuration, download config-2.6.24
    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 kernel-package libdb3-dev libncurses-dev initrd-tools
    
    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", Intel 82845G/GL; ethernet adaptors: "3Com (3c509c-TX)", "Ethernet Pro 1000", "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 
    
    If you like to have a template for configuration, download config-2.6.24
    and copy it into your /usr/src/linux/.config
    Configure the kernel by running command
    make menuconfig
    
  • Compile the Kernel and modules then install the modules
    make dep
    make clean
    make bzImage
    make modules
    make modules_install
    
    Note, compilation of bzImage takes about 15 min. and modules about 35 min. on Dell OptiPlex GX400 (1.3 GHz Pentium 4 machine).
  • Install the Kernel, System map and generate a RAM disk:
    cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.24
    cp System.map /boot/System.map-2.6.24
    mkinitrd -o /boot/initrd.img-2.6.24 2.6.24
    
  • Modify the boot loader (GRUB) to boot into the new kernel by running command
    update-grub
    
    Check file /boot/grub/menu.lst and make sure there are entries for the new kernel:
    default         0
    timeout         5
    color cyan/blue white/blue
    
    title           Debian GNU/Linux, kernel 2.6.24 
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.24 root=/dev/hda1 ro  
    initrd          /boot/initrd.img-2.6.24
    savedefault
    boot
    
    title           Debian GNU/Linux, kernel 2.6.24 (recovery mode)
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.24 root=/dev/hda1 ro  single
    initrd          /boot/initrd.img-2.6.24
    savedefault
    boot
    
    
    title           Debian GNU/Linux, kernel 2.6.18-6-686
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.18-6-686 root=/dev/hda1 ro
    initrd          /boot/initrd.img-2.6.18-6-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.24
    
    If you happen to need to modify and re-build the Kernel in the future, you can copy config-2.6.24 back into /usr/src/linux/.config and run make menuconfig.

  • Create GRUB boot floppy:
       cd /boot/grub
       dd if=stage1 of=/dev/fd0 bs=512 count=1
       dd if=stage2 of=/dev/fd0 bs=512 seek=1
    
    Following the examples in Section GRUB Boot Floppy identify the location of the kernel and root partition on the hard drive as well as the complete names of all the kernels installed on the system and their RAM disks (initrd). Boot one of the Kernels from the GRUB floppy.

  • 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.24 and can be loaded/unloaded at run time. Check what modules are loaded presently by running
    lsmod
    
    Unload modules iptable_filter, ip_tables, x_tables:
    rmmod iptable_filter ip_tables x_tables
    
    Load a module for network packet filtering, x_tables
    insmod /lib/modules/2.6.24/kernel/net/netfilter/x_tables.ko
    
    Run lsmod again to make sure the module is loaded. Unload the module:
    rmmod x_tables.ko 
    
    Run lsmod again to make sure the module has been removed. Try to load module ip_tables.ko
    insmod /lib/modules/2.6.24/kernel/net/ipv4/netfilter/ip_tables.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 ip_tables 
    
    Since it depends on x_tables, try first to load x_tables then ip_tables.
    insmod /lib/modules/2.6.24/kernel/net/netfilter/x_tables.ko
    insmod /lib/modules/2.6.24/kernel/net/ipv4/netfilter/ip_tables.ko
    
    Run lsmod again.
    Unload both the modules:
    rmmod ip_tables 
    rmmod x_tables 
    
    Now, load module ip_tables with all its dependances by:
    modprobe ip_tables 
    
    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