Home Miscellaneous Compiling and installing new kernel in Redhat Linux

Compiling and installing new kernel in Redhat Linux

by Bella

In our example, the current kernel version is 2.6.32.71.

Lets now upgrade the kernel to higher version 3.2

1: Installing Kernel  Dependencies

Installing or Compiling Kernel requires following various required packages and up-to-date system packages.

  1. Latest GCCversion
  2. Latest Ncursesdevelopment version
  3. System packages up-to-date

#  yum install gcc ncurses ncurses-devel

# yum update

Step 2: Downloading Kernel 3.2.71 Source

Download the Kernel 3.2.71 using wget command under /usr/src/  directory. You can also download the latest kernel by going to http://www.kernel.org/

[root@demo ~]# cd /usr/src/

[root@demo src]# wget
https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.71.tar.xz
–2015-08-20 06:38:11–
https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.71.tar.xz
Resolving www.kernel.org… 199.204.44.194, 198.145.20.140, 149.20.4.69, …
Connecting to www.kernel.org|199.204.44.194|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 65649376 (63M) [application/x-xz]
Saving to: “linux-3.2.71.tar.xz”

Step 3: Extracting Kernel 3.2.71 Source

[root@demo src]# tar xvfJ linux-3.2.71.tar.xz
[root@demo src]# cd linux-3.2.71

Step 4: Configuring Kernel 3.2.71 Source

[root@demo linux-3.2.71]# make menuconfig
Now run the make menuconfig command to configure the Linux kernel. Once you execute the below command a pop up window appears with all the menus. Here you can select your new kernel configuration. If you unfamiliar with these menus, just hit ESC key to exit.

For Old Kernel Configuration

If you like to configure your latest kernel with old configuration then simple type the below command.

1k

[root@demo linux-3.2.71]# make oldconfig
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf –oldconfig Kconfig
#
# configuration written to .config
#

Step 5: Compiling Kernel 3.2.71

Next, type the make command to compile the Kernel 3.2.71. The compilation would take at least 40-50 minutes depends on your system configuration.

[root@demo linux-3.2.71]# make

Step 6: Installing Kernel 3.2.71

Once the compilation completes cleanly, now install the Kernel 3.2.71 in your Linux system. The below command will create files under /boot directory and also make a new kernel entry in your grub.conf file.

[root@demo linux-3.2.71]# make modules_install install

Step 7 : Check whether all the necessary files installed under /boot/ directory

[root@demo src]# ll /boot/ | grep 3.2.71
-rw-r–r–. 1 root root 22384840 Aug 20 09:21 initramfs-3.2.71.img
lrwxrwxrwx. 1 root root       23 Aug 20 09:19 System.map ->
/boot/System.map-3.2.71
-rw-r–r–. 1 root root  2372361 Aug 20 09:19 System.map-3.2.71
lrwxrwxrwx. 1 root root       20 Aug 20 09:19 vmlinuz -> /boot/vmlinuz-3.2.71
-rw-r–r–. 1 root root  3960464 Aug 20 09:18 vmlinuz-3.2.71

After installing the kernel, the following entries will be created in the grub config file /etc/grub.conf

—————————-
title Red Hat Enterprise Linux Server (3.2.71)
        root (hd0,6)
        kernel /vmlinuz-3.2.71 ro
root=UUID=23c4fd47-dbb5-4aa4-8c27-2b9fa69b547d rd_NO_LUKS rd_NO_LVM
rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16
KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
        initrd /initramfs-3.2.71.img
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
—————————

Here the default kernel is still the old kernel 2.6.32.71

Step 7 : Perform the reboot

Now do boot once. Boot Once IMPORTANT !! Make the default value correct one.
[root@demo src]# echo “savedefault –default=1 –once” | grub –batch
Probing devices to guess BIOS drives. This may take a long time.

    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> savedefault –default=2 –once

We are executing this command to boot the server from the new kernel. When the new kernel fails, the server will be automatically taken to the old kernel since old kernel is specified on the grub config file.

Reboot using below. This will make sure the server does not go into forces fsck. If this fails, reboot the server with ‘default kernel option’ in /etc/grub.conf and execute the ‘Boot Once’ after reboot.

[root@demo src]# shutdown -rf now

To verify newly installed Kernel just type the following command on the terminal

2k

Thus the kernel has been upgraded from 2.6.32 to 3.2.71

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment