Joomla!

 
  • Increase font size
  • Default font size
  • Decrease font size

Ubuntu Kernel

E-mail Print PDF

Installing a New Kernel

 

One of the frustrations of an easy install from one CD is that regardless of your processor, you will get a generic kernel that may not be well suited for your hardware. This tutorial shows you how to upgrade from the generic kernel that is designed for the Desktop to a kernel that provides better use of a higher end CPU, in this example a Dual Core Xeon. This process can be used to build a real workstation instead of a Desktop. You will get more out of your hardware by making this adjustment.

Note: If you want to compile a whole new kernel for Ubuntu, CLICK HERE. This article will take you step by step.

Kernel Basics
First some basics about the kernel. The Linux kernel is the operating system itself. All other applications are loaded on top of the kernel. The kernel helps the hardware and device drivers to interface. The kernel is loaded into memory when the system starts and remains in memory.

Monolithic Kernels
Monolithic kernels are kernels that have all of the device modules built directly into the kernel. The advantage of the Monolithic kernel is that it can communicate faster as the device modules are built in. Monolithic kernels are not flexible because a new kernel must be built to add any new peripheral devices. This difficulty often then resulted in a huge kernel as the tendency was to build in support for more devices than was needed to avoid having to build a kernel.

Modular Kernels
The Ubuntu kernel is modular. Modular kernels provide many device modules as separate loadable modules so the kernel is much smaller. Modular kernels are slower in communication to modules because they cannot talk with them directly. The Modular kernel is much more flexible and because of size reduces the boot time of the kernel. The modprobe and insmod commands can be used to load modules.

Kernel modules are object files (they have a .o extension) which were produced by the C compiler but were not linked to a completed executable. Thus the process of loading modules creates this executable link to the kernel. The modules are distributed with the kernel and can be found in /lib/modules.

Here is a view of /lib/modules with the default kernel directory.

ls /lib/modules
2.6.22-14-generic

Checking the Kernel Version

To verify which kernel you are running go to the command line and type this command:

uname -r
2.6.22-14-generic

What's The Difference in Kernels
It is not easy to figure out the differences because Ubuntu does not list them, that could be found anyway.

The first difference that you will see is that the generic kernel is set for the i586 and the i686 architectures while the server kernel will focus on the i686 architecture. The reality is that the closer you can tune the kernel to your specific CPU and hardware, the better the performance you will receive. Second, the server kernel will focus on performance and cause the kernel to finish a task before allowing another task to interrupt, while the generic kernel will allow continuous interruptions. In the situation that will be needed for a workstation, finishing a task will be a priority. The generic kernel is limited to 4 GB of RAM, if this is an issue and you want a workstation that can use much more RAM, then you want the server kernel. All in all, the server kernel should provide a modest boost in performance.

Ubuntu 8.04 Training CD

 

Build a Linux Kernel Course

Building Kernels Short Course $29.95

This course is designed to help you understand the various kinds of kernels in Linux and help you go through a step by step process to build a custom kernel. This is a basic course on kernel building. There are 7 projects which are available to gain experience in building kernels. To get the most out of this course you should have a Linux machine that you can build kernels on (a test machine).

 

Installing a New Kernel
The first point to make is that you should not upgrade your kernel, you should install a new one. That way you will have both the old kernel, that you know works, and the new kernel. As root open Synaptic Package Manager from the Administration menu. You will see that you have the generic kernel installed already after doing a search for linux-image.

You have the choice of two other kernels, the linux-image-server and the linux-image-virtual. Choose the linux-image-server if you have an higher end processor so that you will utilize your processor more effectively. The linux-image-virtual is a kernel to use if you will be doing virtualization on the box, like using KVM or XEN.

When you click a kernel image it does provide a basic outline of what it is for.

When you select the new kernel it will also install the required dependencies.

Install and it will give you a summary before the download begins.

 

Once your install of the new kernel is complete you will need to reboot the machine for the new kernel to be placed into action. Reboot and it is all done for you. When you get back to the command line run this command again to verify your new kernel is running:

uname -r
2.6.22-14-server

Now you can see the new kernel is running.

Listing the /boot Contents

You can view the changes that have taken place in two ways. First you can see the new kernel is added to the /boot directory.

ls /boot

Kernels Image Files With Drivers
System Map
vmlinuz-2.6.22-14-generic initrd.img-2.6.22-14-generic System.map-2.6.22-14-generic
vmlinuz-2.6.22-14-server initrd.img-2.6.22-14-generic.bak System.map-2.6.22-14-server
  initrd.img-2.6.22-14-serve 
  initrd.img-2.6.22-14-server.bak 

In addition, you will see the grub directory which contains the menu.lst.


menu.lst
The menu.lst is a text file that contains the list of available kernels for when the system boots. The grub menu is hidden by default when the system boots so you do not see it. To view it at boot time comment out the line that has hiddenmenu.


# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 3

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=a89c3e7b-3b67-4543-8746-6687acea31f1 ro

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title Ubuntu 7.10, kernel 2.6.22-14-server
root (hd0,0)
kernel /vmlinuz-2.6.22-14-server root=UUID=a89c3e7b-3b67-4543-8746-6687acea31f1 ro quiet splash
initrd /initrd.img-2.6.22-14-server
quiet

title Ubuntu 7.10, kernel 2.6.22-14-server (recovery mode)

root (hd0,0)
kernel /vmlinuz-2.6.22-14-server root=UUID=a89c3e7b-3b67-4543-8746-6687acea31f1 ro single
initrd /initrd.img-2.6.22-14-server

title Ubuntu 7.10, kernel 2.6.22-14-generic

root (hd0,0)
kernel /vmlinuz-2.6.22-14-generic root=UUID=a89c3e7b-3b67-4543-8746-6687acea31f1 ro quiet splash
initrd /initrd.img-2.6.22-14-generic
quiet

title Ubuntu 7.10, kernel 2.6.22-14-generic (recovery mode)

root (hd0,0)
kernel /vmlinuz-2.6.22-14-generic root=UUID=a89c3e7b-3b67-4543-8746-6687acea31f1 ro single
initrd /initrd.img-2.6.22-14-generic

title Ubuntu 7.10, memtest86+

root (hd0,0)
kernel /memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST


Each line that has a title followed by a text string presents an option kernel that you can choose at boot time. By default the system boots to 0, which will be the first one listed, that is why it boot to the new one automatically. If you wanted to boot to the second kernel in the list when you booted you can change default to 1, instead of 0.

Now when you look in /lib/modules you will have two kernels listed.

ls /lib/modules
2.6.22-14-generic 2.6.22-14-server

These represent two directories contaniing the modules for each kernel.

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874
 
BeginLinux.com is designed to provide you with Linux Desktop Training, Applications Training and Server Training. Also included are Linux Distribution CDs, manuals and books.

Polls

What type of video training would you like to see?
 

Linux Distro Choices