Delete programs, Edit files pertaining to modules

Securing and Optimizing Linux: RedHat Edition -A Hands on Guide
Prev | Chapter 7. Configuring and Building a Secure, Optimized Kernel | Next

# 7.11. Delete programs, Edit files pertaining to modules

By default when you install Red Hat Linux for the first time like we do, the kernel is built as a modularized kernel. This means that each device or function we need exists as modules and is controlled by the Kernel Daemon program named kmod, which automatically loads some modules and functions support into memory as it is needed, and unloads it when it's no longer being used.

1. kmod and other module management programs included in the modutils RPM package use the `conf.modules` file located in the `/etc` directory to know, for example which Ethernet card you have, if your Ethernet card requires special configuration and so on. Since we are not using any modules in our new compiled kernel, we can remove the `conf.modules` file and uninstall completely the modutils package program. To remove the `conf.modules` file, use the command:

                  [root@deep] /#rm -f  /etc/conf.modules

   To uninstall the modutils package, use the following command:

                  [root@deep] /#rpm -e --nodeps modutils

2. One last thing to do is to edit the file `rc.sysinit` and comment out all the lines related to depmod -a by inserting a `#` at the beginning of the lines. This is needed since at boot time the system read the `rc.sysinit` script to find module dependencies in the kernel by default.

   Comment out the line 260 in the `rc.sysinit` file vi +260 `/etc/rc.d/rc.sysinit`: `if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then`, To read:

                  #if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then

   Comment out the lines 272 to 277 in the `rc.sysinit` file vi +272 `/etc/rc.d/rc.sysinit`:

                  if [ -L /lib/modules/default ]; then
                  INITLOG_ARGS= action "Finding module dependencies" depmod -a default
                  else
                  INITLOG_ARGS= action "Finding module dependencies" depmod -a
                  fi
                  fi

                  To read:
                  #    if [ -L /lib/modules/default ]; then
                  #        INITLOG_ARGS= action "Finding module dependencies" depmod -a default
                  #    else
                  #        INITLOG_ARGS= action "Finding module dependencies" depmod -a
                  #    fi
                  #fi

   > : The procedure described above relates to initscripts-4_70-1 package under Red Hat Linux version 6.1.

   Comment out the line 243 in the `rc.sysinit` file vi +243 `/etc/rc.d/rc.sysinit`: `if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then`, To read:

                  #if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then

   Comment out the lines 255 to 260 in the `rc.sysinit` file vi +255 `/etc/rc.d/rc.sysinit`:

                  if [ -L /lib/modules/default ]; then
                  INITLOG_ARGS= action "Finding module dependencies" depmod -a default
                  else
                  INITLOG_ARGS= action "Finding module dependencies" depmod -a
                  fi
                  fi

   To read:

                  #    if [ -L /lib/modules/default ]; then
                  #        INITLOG_ARGS= action "Finding module dependencies" depmod -a default
                  #    else
                  #        INITLOG_ARGS= action "Finding module dependencies" depmod -a
                  #    fi
                  #fi

   Once again, all of this part Delete program, file and lines related to modules is required only if you said No to `Enable loadable` module support `CONFIG_MODULES` in your kernel configuration above.

3. Now you must Reboot your system and test your results.

                  [root@deep] /#reboot

   When the system is rebooted and you are logged in, verify the new version of your kernel with the following command: To verify the version of your new kernel, use the following command:

                  [root@deep] /#uname -a

   `Linux deep.openna.com 2.2.14 #1 Mon Jan 10 10:40:35 EDT 2000 i686 unknown [root@deep]#`

Congratulation !.

Prev | Home | Next
Installing the new kernel | Up | Create a emergency Rescue and Boot floppy disk