in the server using the command : [root@XXXXX ~]# uname -r
2.6.9-67.ELsmp2.6.9-67.ELsmp
[root@XXXXX ~]#
When make oldconfig prompts for values, retain the old values. Even if you retain the old values, don't forget to check the hardware of the server as well as the processor type and the model of the ethernet card. Since options change with newer kernel versions, and some options may not be there in the old .config files, it is advisable to double check all the options using menuconfig.
Step 2: make menuconfig.
[root@XXXXX ~]#make menuconfig
This is the main screen of menuconfig. Only some options can be compiled as modules. In menuconfig, they are marked < >. Press M to compile as a module. A [*] means compiled in, M means module.
Menuconfig offers search feature. Use "/" to search for any module. For eg: if you are not sure of the location of the module iptables, press "/" , enter the search pattern as "iptables" and press enter.
As there are a lot of options in menuconfig, I will just mention the important ones. The essential options needed for a kernel to be running is processor, file system, network card and hard disk. You can select the desired processor, file system, hard disk and network card from the options available in menuconfig.
Processor type and features
Subarchitecture Type : Select Generic architecture (Summit,bigsmp, ES7000, default)
Processor family : Select the matching processor from the available list. For eg : If the model name is Dual Core AMD Opteron(tm) Processor 170 , you can select Opteron/Athlon64/Hammer/K8 from the options available.
For a multiprocessor server, enable the options Symmetric multi-processing support and SMT (Hyper threading) scheduler support.
For RAM > 4 GB enable the option High Memory Support (64GB) . And the final output of the option Processor type and features would look like this :
Networking
Iptables is enabled in this option.
Location:
-> Networking
-> Networking support (NET [=y])
-> Networking options
-> Network packet filtering (replaces ipchains) (NETFILTER [=y])
-> Core Netfilter Configuration and IP: Netfilter Configuration
All the modules under the option Core Netfilter Configuration and IP: Netfilter Configuration should be enabled as modules.
Device Drivers
This is the most confusing part. In this, the main options you need to check are :
1. Block devices : Enable RAM disk support and Loop back device support
Include Loopback device support (module)
RAM disk support [*} compiled in
Leave the default values of RAM disk number and size.
Initial RAM disk (initrd) support [*} compiled in
2. SCSI device support : Enable corresponding model in SCSI low level drivers if it is a SCSI device.
3. Serial ATA (prod) and Parallel ATA (experimental) drivers: if hard disk is SATA, enable the corresponding driver in this. For eg: if you have Intel PIIX/ICH SATA in the server enable Intel PIIX/ICH SATA support in this option
4. Network device support : Enable the corresponding network card in the server. For eg: if lspci lists the network card as follows :
Ethernet controller: Broadcom Corporation NetXtreme BCM5704 Gigabit Ethernet
Then enable
> Network device support
> Ethernet (1000 Mbit)ss
> Broadcom NetXtremeII support
File Systems
The main modules to be enabled in this section are ext2, ext3, journaling and Quota support.
Once this is complete , save the settings and quit.
5. Build the Kernel
The next step is to build the Kernel. You can use the command make bzImage to do this. This command will create a compressed file bzImage inside arch/i386/boot in the Linux source directory and that is the newly compiled kernel.
The next step is to compile and link the modules. This can be done using the command make modules.
After this you have to copy the modules to /lib/modules/. And this is done using the command make modules_install.
The command sequence is as follows :
make -j bzImage
make -j modules
make -j modules-Install
-j tells your system to do that many jobs in Makefile together which will in turn reduce the time for compilation.
is two times the number of cpus in your system or number of virtual processors. This number can be found using the command
cat /proc/cpuinfo | grep ^processor | wc -l
[root@XXXX]# cat /proc/cpuinfo | grep ^processor | wc -l
2
Once this is done copy all these to the /boot folder as follows :
cp .config /boot/config-2.6.19.2
cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.19.2
cp System.map /boot/System.map-2.6.19.2
mkinitrd /boot/initrd-2.6.9.img 2.6.19.2
mkinitrd is the program to create initial RAM Disk Image.
6. Configure Boot Loader
Boot loader is the first program that runs when a computer boots. There are two types of boot loader :
1. Determine the currently installed boot loader :
Check first 512 bytes of the boot drive. Check for grub first:
# dd if=/dev/hda bs=512 count=1 2>&1 | grep GRUB
If it matches, the current boot loader is grub. Check for lilo if it did not match:
# dd if=/dev/hda bs=512 count=1 2>&1 | grep LILO
Note : If the hard disk is SCSI or SATA, use sda instead of hda..
2. Configure the boot loader
If your boot loader is LILO, add entries for the new kernel in the file /etc/lilo.conf. A typical lilo entry will be as given below :
image=/boot/vmlinuz-2.6.19.2
label=linux
initrd=/boot/initrd-2.6.19.2.img
read-only
append="console=tty0 console=ttyS1,19200n8 clock=pmtmr root=LABEL=/"
Run the command :
lilo -v
/sbin/lilo -R "Label for new kernel"
In the case of GRUB, add the entries for the new kernel at the end of the list of kernels in the file /etc/grub.conf. The first entry in GRUB gets the index 0. An example entry is below :
title Red Hat Linux (2.6.19.2)
root (hd0,0)
kernel /boot/vmlinuz-2.6.19.2 ro root=/dev/hda2 panic=3
initrd /boot/initrd-2.6.19.2
The "panic" parameter ensures that the server reboots to the old kernel, in the case of a kernel panic i.e the machine will be rebooted to the default option in grub.conf, if a panic occurs in 3 secs.
Do Not change the "default" value in the file grub.conf. Enter grub command prompt by typing the command grub at the prompt. Enter the below command at the grub prompt:
savedefault --default=3 --once
This is the case if the newly added entry is having index 3. Exit from grub-shell.
7.Reboot the Server
Reboot the server using the command reboot. If by any chance, a kernel panic occurs, server will be up with the old working kernel. If everything goes fine, the server will be up with the new kernel. Once it is up with the new kernel, do not forget to change the default value in the boot loader.
Conclusion
Booting a newly recompiled kernel in your first attempt is a tough task and is at times thought impossible. Following the above steps and keeping the compilation tricks in mind, there is no doubt Kernel Compilation will now be a piece of cake.
Comments
Post a Comment