royong
20-04-2006, 00:48
Disclaimer :: This article has been primed to focus on the needs to carry out kernel recompilation on a Linux machine so as to add / remove modules to the standard setup. While I take precaution to avoid any unnecessary errata, the reader is advised to perform his / her own backups. I accept no warranties, expressed or implied, with regards to any malfunction, damage, loss, deletion, removal etc. of any form, nor shall I be liable for any damages. This HOWTO has been tested on machines running Red Hat 7.2 / 7.3 / 8.0 - but as usual you are expected to practice due diligence.
Log into the server and as ROOT perform the following :-
# rpm -qa
Ensure that the following RPMs are installed
(a) kernel-source-2.4.18-14
(b) libacl-devel-2.0.11-2
(c) libattr-devel-2.0.8-3
(d) tcl-8.3.3-74
(e) tk-8.3.3-74
If they aren't, please get them installed before proceeding further.
# vi /usr/src/linux-2.4/MakeFile
Edit the EXTRAVERSION entry. Change the definition for EXTRAVERSION=versionnumber to something that uniquely identifies your custom kernel. Anything goes. Just be sure to remember what you have entered. For our case, we shall use EXTRAVERSION=RHcustom
# make mrproper
This ensures that your files are in a consistent and clean state
# make oldconfig
This uses the standard Red Hat configuration that is provided in the /usr/src/linux-2.4/configs/ directory. Once this command completes, we can then run a configuration utility to configure or custom the kernel to your liking. Use any ONE of the following configuration tools.
# make config
(This is a the standard configuration tool - can be run via SSH)
# make menuconfig (This is a menu based configuration tool that uses NCURSES)
# make xconfig (This is a GUI based configuration tool that requires X-Windows)
Carry out any customization as you may require. Save and quit the configuration tool.
# make dep
This will set up all your dependencies correctly. This tales the setting present in /usr/src/linux-2.4/.config and pushes them down into the correct source code subdirectory
# make modules
This helps to build all the modules that is required for the customized kernel. This step is extremely time consuming. Anything from 30 to 60 minutes is considered standard.
With the completion of make modules we are now ready to move it to the /boot before we can actually use it.
# cp /usr/src/linux-2.4/arch/i386/boot/bzImage /boot/vmlinuz-2.4.19-RHcustom
# make modules_install
This installs all the newly made modules to correspond with the kernel release and EXTRAVERSION setting of your custom kernel. If this name already exists, it will be overwritten. As such, always remember to set a unique EXTRAVERSION value for each custom kernel.
# make install
This command automates the process a little. No need to mkinitrd, copy the kernel symbol table and edit the grub.conf file manually. This single command should automate the process without any hitches. Once this command is complete, we just need to run a check on the grub.conf file to ensure that the changes are reflected as they should.
# cat /etc/grub.conf
Looking at our GRUB loader configuration file, you should have something very similar to the following :
Title Red Hat Linux (2.4.19-6)
root (hd0,0)
kernel /vmlinuz-2.4.19-6 ro root=LABEL=/
initrd /initrd-2.4.19-6.img
Title Red Hat Linux (2.4.19-RHcustom)
root (hd0,0)
kernel /vmlinuz-2.4.19-RHcustom ro root=LABEL=/
initrd /initrd-2.4.19-RHcustom.img
That's it. You are ready to reboot your machine. Upon boot up, you should see another entry in your GRUB loader menu. Selecting on the Red Hat Linux (2.4.19-RHcustom) entry would initialize the system to boot via your custom kernel. Barring any errors, your system should boot up without a hitch and there you have it. Your every own custom kernel for your machine. Enjoy !
*Note : To change the default boot selection in the GRUB menu, we will need to change the value of the default variable in the /etc/grub.conf file. If default=0, the default kernel loaded will be the first entry while a default=1 value will load the second entry.
Log into the server and as ROOT perform the following :-
# rpm -qa
Ensure that the following RPMs are installed
(a) kernel-source-2.4.18-14
(b) libacl-devel-2.0.11-2
(c) libattr-devel-2.0.8-3
(d) tcl-8.3.3-74
(e) tk-8.3.3-74
If they aren't, please get them installed before proceeding further.
# vi /usr/src/linux-2.4/MakeFile
Edit the EXTRAVERSION entry. Change the definition for EXTRAVERSION=versionnumber to something that uniquely identifies your custom kernel. Anything goes. Just be sure to remember what you have entered. For our case, we shall use EXTRAVERSION=RHcustom
# make mrproper
This ensures that your files are in a consistent and clean state
# make oldconfig
This uses the standard Red Hat configuration that is provided in the /usr/src/linux-2.4/configs/ directory. Once this command completes, we can then run a configuration utility to configure or custom the kernel to your liking. Use any ONE of the following configuration tools.
# make config
(This is a the standard configuration tool - can be run via SSH)
# make menuconfig (This is a menu based configuration tool that uses NCURSES)
# make xconfig (This is a GUI based configuration tool that requires X-Windows)
Carry out any customization as you may require. Save and quit the configuration tool.
# make dep
This will set up all your dependencies correctly. This tales the setting present in /usr/src/linux-2.4/.config and pushes them down into the correct source code subdirectory
# make modules
This helps to build all the modules that is required for the customized kernel. This step is extremely time consuming. Anything from 30 to 60 minutes is considered standard.
With the completion of make modules we are now ready to move it to the /boot before we can actually use it.
# cp /usr/src/linux-2.4/arch/i386/boot/bzImage /boot/vmlinuz-2.4.19-RHcustom
# make modules_install
This installs all the newly made modules to correspond with the kernel release and EXTRAVERSION setting of your custom kernel. If this name already exists, it will be overwritten. As such, always remember to set a unique EXTRAVERSION value for each custom kernel.
# make install
This command automates the process a little. No need to mkinitrd, copy the kernel symbol table and edit the grub.conf file manually. This single command should automate the process without any hitches. Once this command is complete, we just need to run a check on the grub.conf file to ensure that the changes are reflected as they should.
# cat /etc/grub.conf
Looking at our GRUB loader configuration file, you should have something very similar to the following :
Title Red Hat Linux (2.4.19-6)
root (hd0,0)
kernel /vmlinuz-2.4.19-6 ro root=LABEL=/
initrd /initrd-2.4.19-6.img
Title Red Hat Linux (2.4.19-RHcustom)
root (hd0,0)
kernel /vmlinuz-2.4.19-RHcustom ro root=LABEL=/
initrd /initrd-2.4.19-RHcustom.img
That's it. You are ready to reboot your machine. Upon boot up, you should see another entry in your GRUB loader menu. Selecting on the Red Hat Linux (2.4.19-RHcustom) entry would initialize the system to boot via your custom kernel. Barring any errors, your system should boot up without a hitch and there you have it. Your every own custom kernel for your machine. Enjoy !
*Note : To change the default boot selection in the GRUB menu, we will need to change the value of the default variable in the /etc/grub.conf file. If default=0, the default kernel loaded will be the first entry while a default=1 value will load the second entry.