1.4. Exercises and Summary

FilesDescription
/etc/modules.confused by modprobe before inserting a module
/lib/modules/kernel-version/directory where the modules for given kernel version are stored
/lib/modules/kernel-version/modules.deplist of module dependencies created by depmod
CommandDescription
depmodSee depmod(8). kernel modules can provide services (called "symbols") for other modules to use (using EXPORT_SYMBOL in the code). If a second module uses this symbol, that second module clearly depends on the first module. depmod creates a list of module dependencies, by reading each module under /lib/modules/version and determining what symbols it exports, and what symbols it needs. By default this list is written to modules.dep in the same directory
insmodSee insmod(8). A trivial program to insert a module into the kernel: if the filename is a hyphen, the module is taken from standard input. Most users will want to use modprobe(8) instead, which is cleverer
make cleandelete all object files in the source tree
make configconfigure the Linux kernel
make depcreates a list of extra headers in files called .depend needed to satisfy module dependencies
make menuconfigconfigure the Linux kernel using a menu
make modulescompile all the external/dynamic modules for this kernel
make modules_installinstall the compiled modules in /lib/module/kernel-version
make oldconfigcreate a default .config if it doesn't exist. If a .config file already exists the chosen configuration is unchanged. If the source tree has changed, for example after a patch (see LPI 201) or the .config file corresponds to an older kernel, then extra configuration options must be supplied
make xconfigconfigure a Linux kernel using a menu
lsmodlist all dynamically loaded modules
modinfoprint information about a kernel module such as the author (-a), the description (-d), the license (-l) or parameters (-p)
modprobeSee modprobe(8). Will automatically load all base modules needed in a module stack, as described by the dependency file modules.dep. If the loading of one of these modules fails, the whole current stack of modules loaded in the current session will be unloaded automatically
rmmodSee rmmod(8). Tries to unload a set of modules from the kernel, with the restriction that they are not in use and that they are not referred to by other modules

Before starting with the exercises make sure you dont have an existing kernel tree in /usr/src/. If you do, pay attention to the /usr/src/linux symbolic link.

  1. Manually recompile the kernel following the compilation steps.

    • Get the kernel-version.src.rpm package from an FTP mirror site or a CD. Installing this package will also give you a list of dependencies, such as the gcc compiler or binutils package if they haven't yet been met.

    • Install the package with -i (this will put all the code in /usr/src/)

    • Go into the /usr/src/linux-version directory and list the configs directory

    • Copy the kernel config file that matches your architecture into the current directory and call it .config

    • Run

      make oldconfig

      at the command line to take into account this new .config file.

    • Edit the Makefile and make sure the version is not the same as your existing kernel. You can get information on your current kernel by running uname -a at the command line or list the /lib/modules directory.

    • Run

      make menuconfig  # or menu or xconfig

      and remove ISDN support from the kernel.

    • When you exit the above program the .config file is altered but the changes have not yet taken place in the rest of the source tree. You next need to run

      make dep
    • Finally to force new object files (.o) to be compiled with these changes you delete all previously compiled code with

      make clean
    • You can now build the kernel the modules and install the modules with:

      make bzImage modules modules_install
    • The modules are now installed in the /lib/modules/version directory. The kernel is called bzImage and is in the /usr/src/linux/arch/i386/boot/ directory. We need to manually install this kernel (2 steps):

      1. cp /usr/src/linux/arch/i386/boot/bzImage \
        /boot/vmlinuz-full-kernel-version
        
      2. That was easy so far! We next edit the bootloader configuration file:

        • If you are using LILO, edit /etc/lilo.conf and add an image paragraph that will tell LILO where to find this kernel and the root filesystem. Run /sbin/lilo and reboot

        • If you are using GRUB, edit /boot/grub/grub.conf or /boot/grub/menu.lst

  2. Since we downloaded the kernel-version.src.rpm package we can now use this package to recompile a RedHat preconfigured kernel. Notice that although no intervention is needed you wont be able to change the .config menu.

    • First rebuild the compiled binary package with

      rpm --rebuild kernel-version.src.rpm     # ...wait!
    • This will eventually generate the kernel-version.i368.rpm in /usr/src/redhat/RPMS/i386/.

    • Next, upgrade you kernel with the RPM manager using the -U option.