This section applies to both the Monolithic and Modularized kernel. Ok, the kernel has been configured, compiled and is now ready to be installed your system. Below are the steps required to install all the necessary kernel components in your system.
Step 1
Copy the file /usr/src/linux/arch/i386/boot/bzImage from the kernel source tree to the /boot directory, and give it an appropriate new name.
• To copy the bzImage file to the /boot directory, use the following commands: [root@deep /]# cd /usr/src/linux/ (if you are not already in it)
Kernel Security & Optimization 0 CHAPTER 6
Step 2
A new System.map file is generated when you compile a kernel, and is a list of all the addresses in that kernel and their corresponding symbols. Every time that you create a new kernel, such a file System.map is created and saved in /usr/src/linux. It's a text file, which is read by a few programs to do address <-> symbol translation, and which you need if you ever get an Oops. Certain commands, like klog, ps, and lsof, use the System.map file to get the name of kernel symbols. Without it some commands like lsof will complain that they can't find a System.map file to match the currently booted kernel.
Copy the file /usr/src/linux/System.map from the kernel source tree to the /boot directory, and give it an appropriate new name.
• To copy the System.map file to the /boot directory, use the following commands: [root@deep /]# cd /usr/src/linux/ (if you are not already in it)
[root@deep linux]# cp System.map /boot/System.map-2.4.18
Step 3
Move into the /boot directory and rebuild the links vmlinuz and System.map.
• To rebuild the vmlinuz and System.map files, use the following commands:
[root@deep linux]# cd /boot/
[root@deep /boot]# ln -fs vmlinuz-2.4.18 vmlinuz
[root@deep /boot]# ln -fs System.map-2.4.18 System.map
We must rebuild the links of vmlinuz and System.map to point them to the new installed kernel version. Without the new links LILO or GRUB program will look, by default, for the old version of your Linux kernel.
Step 4
Remove obsolete and unnecessary files under the /boot directory to increase disk space:
• To remove obsolete and unnecessary files under the /boot directory, use commands: [root@deep /]# cd /boot/ (if you are not already in it)
[root@deep /boot]# rm -f module-info
[root@deep /boot]# rm -f initrd-2.4.x.img
The module-info is a link, which points to the old modules directory of your original kernel. Since we have installed a brand new kernel, we don’t need to keep this broken link.
The initrd-2.4.x.img is a file that contains an initial RAM disk image that serves as a system before the disk is available. This file is only available and is installed by the Linux initial setup installation if your system has a SCSI adapter present and only if your system has a SCSI adapter. If we use and have a SCSI system, the required driver now will have been incorporated into our new Linux kernel since we have build it by answering Y to the question related to our SCSI model during the configuration of the kernel, so we can safely remove this file (initrd- 2.4.x.img).
Step 5
Create a new Linux kernel directory that will handle all the header files related to Linux kernel for future compilation of other programs on your system.
Recall, we had created two symlinks under the /usr/include directory that pointed to the Linux kernel header files to be able to compile it without receiving errors and also be able to compile future programs. The /usr/include directory is where all the header files for your Linux system are kept for reference and dependencies when you compile and install new programs.
The asm, and linux links are used when programs need to know some functions which are compile-time specific to the kernel installed on your system. Programs call other headers as well in the /usr/include directory when they must know specific information, dependencies, etc of your system.
• To create a new Linux kernel directory to handle all header files, use the commands:
[root@deep /]# mkdir -p /usr/src/linux-2.4.18/include
[root@deep /]# cd /usr/src/linux/
[root@deep linux]# cp -r include/asm-i386 ../linux-2.4.18/include/
[root@deep linux]# cp -r include/linux ../linux-2.4.18/include/
[root@deep linux]# cd ../
[root@deep src]# rm -rf /usr/src/linux
[root@deep src]# cd /usr/src/ (to be sure that we are into the src directory)
[root@deep src]# ln -s /usr/src/linux-2.4.18 linux
First we create a new directory named “linux-2.4.18” based on the version of the kernel we have installed for easy interpretation, then we copy directories asm-i386, and linux from /usr/src/linux/include to our new location /usr/src/linux-2.4.18/include. After we remove the entire source directory where we compiled the new kernel, we create a new symbolic link named “linux” under /usr/src that points to our new /usr/src/linux- 2.4.18 directory. With these steps, future compiled programs will know where to look for headers related to the kernel on your server.
NOTE: This step will allow us to gain space on our hard drive and will reduce the security risks. The Linux kernel source directory handles a lot files and is about 94M in size when
uncompressed. With the procedure described above, our Linux kernel directory began approximately 4M in size so we save 90MB for the same functionalities.