With the kernel configured, you are ready to build it. Just type make bzImage.
This command runs the kernel source code through the Linux C
compiler. So far, you only built the kernel proper; everything you modularized during configuration needs to be built as well. Just type make modules to build the modules.
Installing the Kernel and Modules
- Now that you have built the kernel and modules, you need to install them.
The following steps install the kernel and modules.
- Step 1:
cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-(version)
- Step 2:
cp /usr/src/linux/System.map /boot/System.map-(version)
- Step 3:
make modules_install
Steps one and two copy the kernel and system map (a file that holds kernel symbols for the new kernel) to the /boot partition, the Red Hat Linux kernel's standard location. Step three installs the modules. You will need to replace (version) above with the major, minor, patch level, and extra version information of your kernel. For example, if you were building a 2.2.16 kernel from Red Hat's 2.2.16-3 kernel source, with Red Hat's EXTRAVERSION value of3, you would replace (version) above with 2.2.16-3r1.
View the series of images below to see the build and installation for both the kernel and modules.
As a Red Hat Linux Administrator tasked with building and installing the kernel and modules in Red Hat Linux 7.7, you'll need to keep several important considerations in mind. This is an advanced task that requires a deep understanding of Linux, knowledge of hardware, and the implications of the changes being made. Missteps during this process can result in system instability or render the system unbootable.
- Hardware Compatibility: Before proceeding, ensure that the kernel you're planning to build supports all the hardware components used by your system. Check hardware compatibility lists and kernel documentation.
- Software Compatibility: Software running on your system may have specific kernel dependencies. Make sure to verify the compatibility of your applications with the kernel version you're building.
- Kernel Configuration: The kernel configuration file determines what features are included in your custom kernel. You need to understand these options and configure them appropriately. You can start from the existing configuration file (/boot/config-$(uname -r)) and modify it to suit your needs.
- Building Process: Building a custom kernel is a resource-intensive task. Make sure your system has enough memory and processing power to handle the build process.
- Backup: Always keep a backup of your current working kernel and configuration. In the event of a failure with your new kernel, you'll need a way to restore the system to a working state.
- Testing: Once the kernel is built and installed, you'll need to reboot the system to use the new kernel. This can be risky if the system is serving production traffic. Consider testing your custom kernel on a non-production system first.
- Documentation: Keep detailed notes and documentation on the changes you make. This will be helpful when troubleshooting and also in the future when you might need to replicate or reverse the process.
- Troubleshooting: Be prepared for problems and have a strategy in place to troubleshoot. Common tools include boot logs, dmesg, and the system logs.
- Updates and Maintenance: Custom kernels won't receive updates from your distribution's package manager. You'll need to manage updates manually. Keep in mind the impact this might have on your system's security and stability
- Grub Configuration: Be cautious while configuring GRUB (GRand Unified Bootloader).
A misconfiguration can prevent the system from booting.
Here's a general guideline for the process:
- Install the necessary packages to build the kernel (gcc, make, ncurses-dev, bison, flex, libssl-dev).
- Download the source code for the kernel you want to build.
- Extract the source code and navigate to the directory.
- Configure the kernel features (using 'make menuconfig' or similar).
- Build the kernel and modules.
- Install the new kernel and modules.
- Update the bootloader to include the new kernel.
- Reboot and select the new kernel from the bootloader.