1. First of all, download the 2.6.32.10 Kernel to /usr/src/ on your server.
[root]# wget http://www.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.10.tar.gz
2. Extract this archive now:
[root]# tar xzf linux-2.6.32.10.tar.gz
3. After that, download the patch which matches the kernel version you are using. In this case:
[root]# wget http://download.openvz.org/kernel/branches/2.6.32/current/patches/patch-dyomin.1-combined.gz
4. Now you have to do the following steps:
4.a. Adding the OpenVZ repository
[root]# cd /etc/yum.repos.d
[root]# wget http://download.openvz.org/openvz.repo
[root]# rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
[root]# rpm -e ovzkernel --nodeps
4.b. Updating the packages
[root]# yum update
[root]# yum upgrade
4.c. Installing OpenVZ
[root]# yum install vzctl
4.d. Removing the old Kernel
[root]# cd /usr/src/
[root]# rm linux -rf
[root]# ln -s linux-2.6.24 linux
5. Applying the patch:
[root]# gunzip patch-dyomin.1-combined.gz
[root]# patch -p0 < patch-dyomin.1-combined
6. Configuring the new Kernel:
[root]# wget server.lu/openvz.config.32
or if you are using 64Bit:
[root]# wget server.lu/openvz.config.64
7. Then for 32 Bit:
[root]# cp openvz.config.32 linux/.config
or 64 Bit:
[root]# cp openvz.config.64 linux/.config
8. Editing the OpenVZ configuration file
8.a. The next step is to edit the vz configuration file:
[root]# vi /etc/vz/vz.conf
Uncomment the following line:
#MODULES_DISABLED=yes
to
MODULES_DISABLED=yes
Save the changes and exit the editor.
9. Compiling the Kernel
The following step is very important:
[root]# cd linux
[root]# make menuconfig
10. Select to load an alternative configuration file and load the .config file (Normally you only have to hit "return")
Now quit this menu.
So let's compile the Kernel. This can take a while, depending on which server you are using.
11. Execute:
[root]# make
The last step is to copy the newly compiled kernel to the /boot folder:
32Bit:
[root]# cp arch/i386/boot/bzImage /boot/
[root]# cp System.map /boot/
or 64 Bit:
[root]# cp arch/x86_64/boot/bzImage /boot/
[root]# cp System.map /boot/
Now reboot your server. If you have done everything right, the server should reboot without any problems.
Kernel Upgrade:
Steps:
[root]# wget hhttp://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.1.tar.gz
[root]# tar -xzf http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.1.tar.gz
[root]# ll
[root]# cd linux-2.6.32.1/
[root]# rpm -qa | grep -i kernel
[root]# uname -r
[root]# cd /usr/src/ls
[root]# cd linux-2.6.28.9/
[root]# ls -al .config
[root]# cp -ap .config /root/linux-2.6.32.1
[root]# cd /root/linux-2.6.32.1
[root]# cat .config
[root]# make menuconfig
[root]# make
[root]# make modules_install
[root]# cat /etc/grub.conf
[root]# make install
[root]# cat /etc/grub.conf
[root]# ls /boot/
[root]# ps -ef
[root]# cat /etc/inittab
[root]# runlevel
[root]# cat /etc/rc.d/rc.sysinit
[root]# cat /etc/fstab
[root]# vi /etc/inittab
[root]# cat /etc/grub.conf
change the default grub loader to newly installed kernel. The first entry in GRUB gets the index 0. An example entry is below :
title Red Hat Linux (2.6.32.1)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32.1 ro root=/dev/hda2 panic=3
initrd /boot/initrd-2.6.32.1
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:
[root]# savedefault --default=3 --once
[root]# 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.
Recompiling kernel:
Steps:
1. Download and extract the new kernel package:
[root]#cd /usr/src/kernels
[root]#wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.1.tar.gz
[root]#tar zxf linux-2.6.32.1.tar.gz
[root]#cd linux-2.6.32.1
2. Checking the current Kernel configuration:
[root]# lsmod
libata 105757 1 sata_svw
lsmod displays a module sata_svw and more details of this module can be obtained as shown below.
[root]# modinfo sata_svw
3. Copy the current kernel configuration to your new kernel source.
[root]#pwd
/usr/src/kernels/linux-2.6.19.2
[root]#cp /boot/config-linux-2.6.24 .config
[root]#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.
4. Building Kernel:
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.
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.
5. Compiling and Linking:
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<Number> bzImage
make -j<Number> modules
make -j<Number> modules-Install
-j tells your system to do that many jobs in Makefile together which will in turn reduce the time for compilation.
<Number> 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]# 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.32.1
cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.32.1
cp System.map /boot/System.map-2.6.32.1
mkinitrd /boot/initrd-2.6.32.img 2.6.32.1
mkinitrd is the program to create initial RAM Disk Image.
6. Configure Boot Loader:
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.32.1)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32.1 ro root=/dev/hda2 panic=3
initrd /boot/initrd-2.6.32.1
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:
[root]# savedefault --default=3 --once
7. Reboot the server using the command:
[root]# 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.
No comments:
Post a Comment