Back to the main page

Building new Kernel

Check the Kernel before update, it's 2.6.39-400.282.1.el6uek

[root@milan ~]#  uname -a 
Linux milan 2.6.39-400.282.1.el6uek.x86_64 #1 SMP Thu Jun 30 18:38:25 PDT 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@milan ~]#  rpm -qi kernel-uek-2.6.39-400.282.1.el6uek 
Name        : kernel-uek                   Relocations: (not relocatable)
Version     : 2.6.39                            Vendor: Oracle America
Release     : 400.282.1.el6uek              Build Date: Thu 30 Jun 2016 07:02:38 PM PDT
Install Date: Sun 03 Jul 2016 03:00:50 PM PDT      Build Host:
Group       : System Environment/Kernel     Source RPM: kernel-uek-2.6.39-400.282.1.el6uek.src.rpm
Size        : 120045759                        License: GPLv2
Signature   : RSA/8, Thu 30 Jun 2016 07:13:49 PM PDT, Key ID 72f97b74ec551f03
URL         :
Summary     : The Linux kernel
Description :
The kernel package contains the Linux kernel (vmlinuz), the core of any
Linux operating system.  The kernel handles the basic functions
of the operating system: memory allocation, process allocation, device
input and output, etc.

[root@milan ~]#  cat /boot/grub/grub.conf | grep 2.6.39-400.282.1.el6uek 

title Oracle Linux Server Unbreakable Enterprise Kernel (2.6.39-400.282.1.el6uek.x86_64)
  kernel /vmlinuz-2.6.39-400.282.1.el6uek.x86_64 ro root=/dev/mapper/vg_milan-lv_root nomodeset rhgb quiet
  initrd /initramfs-2.6.39-400.282.1.el6uek.x86_64.img

Method I: Update kernel using yum command

[root@milan yum.repos.d]#  yum update kernel-uek 

Resolving Dependencies
--> Running transaction check
---> Package kernel-uek.x86_64 0:2.6.39-400.283.1.el6uek will be installed
--> Processing Dependency: kernel-uek-firmware = 2.6.39-400.283.1.el6uek for package: kernel-uek-2.6.39-400.283.1.el6uek.x86_6          4
--> Running transaction check
---> Package kernel-uek-firmware.noarch 0:2.6.39-400.283.1.el6uek will be installed
--> Finished Dependency Resolution
--> Running transaction check
---> Package kernel-uek.x86_64 0:2.6.39-400.264.5.el6uek will be erased
---> Package kernel-uek-firmware.noarch 0:2.6.39-400.264.5.el6uek will be erased
--> Finished Dependency Resolution

Dependencies Resolved
 Package                        Arch              Version                Repository         
 kernel-uek                     x86_64    2.6.39-400.283.1.el6uek      ol6_UEK_latest 
 kernel-uek                     x86_64    2.6.39-400.264.5.el6uek      @public_ol6_UEK_latest 
 kernel-uek-firmware            noarch    2.6.39-400.264.5.el6uek      @public_ol6_UEK_latest
Installing for dependencies:
 kernel-uek-firmware            noarch    2.6.39-400.283.1.el6uek      ol6_UEK_latest 
Is this ok [y/N]:

... shortened ...

  kernel-uek.x86_64 0:2.6.39-400.264.5.el6uek<--- Removed old "leftover" kernel    
  kernel-uek-firmware.noarch 0:2.6.39-400.264.5.el6uek<--- Removed old "leftover" kernel  

  kernel-uek.x86_64 0:2.6.39-400.283.1.el6uek <--- Installed new Kernel

Dependency Installed:
  kernel-uek-firmware.noarch 0:2.6.39-400.283.1.el6uek

[root@milan yum.repos.d]#  cat /boot/grub/grub.conf | grep 283 

title Oracle Linux Server Unbreakable Enterprise Kernel (2.6.39-400.283.1.el6uek.x86_64)
      kernel /vmlinuz-2.6.39-400.283.1.el6uek.x86_64 ro root=/dev/mapper/vg_milan-lv_root nomodeset rhgb quiet
      initrd /initramfs-2.6.39-400.283.1.el6uek.x86_64.img

This way of installation update (by removing old and adding new kernel) /boot/grub/grub.conf file. It also add new kernel (vmlinuz) and initrd and to /boot/ directory, and remove files related to old kernel.

If there are some older kernels, they can be removed with commands.
# rpm -e --test <kernel-old-version>
# yum remove <kernel-old-version>

It also removes that old kernel from /boot/grub/grub.conf file. The system still runs with old kernel (2.6.39-400.282.1.el6uek), so let's reboot to run new one (2.6.39-400.283.1.el6uek).
Yes, all looks good.

[root@milan ~]#  uname -r 

Actually, it may be good idea to leave "default" kernel to be old one and you manually select new kernel for booting. Just in case there is problem and you cannot boot (like some kernel panic message), so you can always reboot system and boot in old known good kernel.

Method II: Manually build new kernel from

Get kernel (for example linux-3.2.81) from and put it in /kernelbuild/ directory. The downloaded file is linux-3.2.81.tar.xz
Make sure gcc is installed, it will be needed for running "make menuconfig", which is configuring features for new kernel.

Uncompress and untar the file linux-3.2.81.tar.xz
# unxz linux-3.2.81.tar.xz
# tar -xvf linux-3.2.81.tar
# cd /kernelbuild/linux-3.2.81

[root@milan linux-3.2.81]#  make menuconfig 
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf Kconfig
# using defaults found in /boot/config-2.6.39-400.283.1.el6uek.x86_64
/boot/config-2.6.39-400.283.1.el6uek.x86_64:491:warning: symbol value 'm' invalid for ACPI_APEI_GHES
 .config - Linux/x86_64 3.2.81 Kernel Configuration

Then use this menu to configure kernel features.

Save new configuration in the file named .config

Compile the kernel.

[root@milan linux-3.2.81]#  make dep 
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
# configuration written to .config
*** Warning: make dep is unnecessary now.

[root@milan linux-3.2.81]# make clean

.. it's okay if there is no output ..

[root@milan linux-3.2.81]# make bzImage
  CHK     include/linux/version.h
  UPD     include/linux/version.h
  CHK     include/linux/utsrelease.h
  UPD     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-x86
  HOSTCC  scripts/basic/fixdep
.... shortened 
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  HOSTCC  arch/x86/boot/tools/build
  BUILD   arch/x86/boot/bzImage
Setup is 14892 bytes (padded to 15360 bytes).
System is 3870 kB
CRC f4cc0adf
Kernel: arch/x86/boot/bzImage is ready  (#1)

Make sure bzImage has 755 permissions! Copy bzImage to /boot/ directory and rename it to "vmlinuz-<version>"

#  cp -p /kernelbuild/linux-3.2.81/arch/x86/boot/bzImage /boot/vmlinuz-3.2.81 

Copy (it's maping hexadecimal numbers to meaningful words, this helps with troubleshoot) to /boot/

# head /kernelbuild/linux-3.2.81/ 
0000000000000000 A VDSO32_PRELINK
0000000000000000 D __per_cpu_start
0000000000000000 D irq_stack_union
0000000000000000 A xen_irq_disable_direct_reloc
0000000000000000 A xen_save_fl_direct_reloc
0000000000000040 A VDSO32_vsyscall_eh_frame_size
00000000000001e9 A kexec_control_code_size

#  cp -p /kernelbuild/linux-3.2.81/ /boot/ 

Compile modules

[root@milan linux-3.2.81]#  make modules 
make[1]: Nothing to be done for `relocs'.
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/
  AS [M]  arch/x86/crypto/aes-x86_64-asm_64.o
  CC [M]  arch/x86/crypto/aes_glue.o
  AS [M]  arch/x86/crypto/aesni-intel_asm.o
  -- shortened --
  IHEX    firmware/edgeport/down3.bin
  IHEX2FW firmware/whiteheat_loader.fw
  IHEX2FW firmware/whiteheat.fw
  IHEX2FW firmware/keyspan_pda/keyspan_pda.fw
  IHEX2FW firmware/keyspan_pda/xircom_pgs.fw

Install modules
# make modules_install

-- shortened --
  INSTALL /lib/firmware/edgeport/down2.fw
  INSTALL /lib/firmware/edgeport/down3.bin
  INSTALL /lib/firmware/whiteheat_loader.fw
  INSTALL /lib/firmware/whiteheat.fw
  INSTALL /lib/firmware/keyspan_pda/keyspan_pda.fw
  INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw
  DEPMOD  3.2.81

Modules will be installed in /lib/modules/

# ls -la /lib/modules/
total 20
dr-xr-xr-x.  5 root root 4096 Aug  2 07:05 .
dr-xr-xr-x. 11 root root 4096 Aug  1 23:12 ..
drwxr-xr-x.  7 root root 4096 Jul  3 15:03 2.6.39-400.282.1.el6uek.x86_64
drwxr-xr-x.  7 root root 4096 Aug  1 22:25 2.6.39-400.283.1.el6uek.x86_64
drwxr-xr-x.  3 root root 4096 Aug  2 07:08 3.2.81

[root@milan 3.2.81]# du -sh /lib/modules/3.2.81/
1.3G    /lib/modules/3.2.81/

[root@milan 3.2.81]# ls /lib/modules/3.2.81/
build              modules.builtin      modules.dep.bin      modules.ofmap     modules.softdep      source
kernel             modules.builtin.bin  modules.ieee1394map  modules.order     modules.symbols
modules.alias      modules.ccwmap       modules.inputmap     modules.pcimap    modules.symbols.bin
modules.alias.bin  modules.dep          modules.isapnpmap    modules.seriomap  modules.usbmap

Now initrd can be created.

The initial RAM disk (initrd) is an initial root file system that is mounted prior to real root file system. The initrd is bound to the kernel and loaded as part of the kernel boot procedure.
The kernel then mounts this initrd as part of the two-stage boot process to load the modules to make the real file systems available and mounted.
The initrd contains a minimal set of directories and executables to achieve this, such as the insmod tool to install kernel modules into the kernel.

[root@milan tmp]#  mkinitrd -v /boot/initrd-3.2.81.img 3.2.81 
I: Executing /sbin/dracut -v /boot/initrd-3.2.81.img 3.2.81
I: Installing /lib64/
I: Installing /lib64/
I: Installing /bin/dash
I: Installing /lib64/
I: Installing /lib64/
--- shortened
I: Stripping '/tmp/initramfs.UGwlkN/lib/udev/edd_id'
I: Stripping '/tmp/initramfs.UGwlkN/lib/'
I: Wrote /boot/initrd-3.2.81.img
I: -rw-------. 1 root root 18227808 Aug 2 07:21 /boot/initrd-3.2.81.img
The "-v" for verbose output since mkinitrd is silent.

Add lines to /boot/grub/grub.conf but again, just in case, don't setup as default.
title Kernel from (3.2.81, built manually)
        root (hd0,0)
        kernel /vmlinuz-3.2.81 ro root=/dev/mapper/vg_milan-lv_root nomodeset rhgb
        initrd /initrd-3.2.81.img

... and reboot computer and manually select kernel 3.2.81. Works. Now you can setup this new kernel to be default for booting.
[root@milan ~]# uname -a
Linux milan 3.2.81 #1 SMP Tue Aug 2 19:51:44 PDT 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@milan ~]# uname -r

Again, older kernels (installed via rpm/yum) can be removed with command:
# yum remove kernel-<version>

This command will remove rpm, remove coresponding lines from /boot/grub/grub.conf, remove coresponding directory under /lib/modules and remove coresponding files (vmlinuz, initrd, from /boot directory.

Back to the main page