0% found this document useful (0 votes)
48 views

Ch11 Kernel

The document discusses the Linux kernel. It begins by defining the kernel's objectives and properties. It then discusses kernel version numbering, recent changes, and preparing to build a new kernel. The remainder of the document provides instructions on obtaining the kernel source code and tools, configuring and compiling a new kernel, installing modules, and configuring LILO to boot the new kernel.

Uploaded by

m3onh0x84
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Ch11 Kernel

The document discusses the Linux kernel. It begins by defining the kernel's objectives and properties. It then discusses kernel version numbering, recent changes, and preparing to build a new kernel. The remainder of the document provides instructions on obtaining the kernel source code and tools, configuring and compiling a new kernel, installing modules, and configuring LILO to boot the new kernel.

Uploaded by

m3onh0x84
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

Chapter 11

KERNEL

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Objectives

Define kernel properties


Demonstrate new kernel preparation
Identify and use kernel configuration tools
Recompile and install a kernel
Identify kernel modules
Configure LILO to use a new kernel

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
The Linux Kernel

It’s loaded at initial bootup of Linux system,


manages activities : I/O, memory, processes, network
interface,…
Why would you want to build a new kernel ?
(newer hardware, faster, more stable, …)
Kernel can be built with 2 basic options :
– Device drivers can be built directly into the
kernel binary itself (monolithic)
– Device drivers can be built as external modules
to the kernel (modular)
SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Kernel Version Numbering

Kernel version numbers are made by three basic


components:
– The major number
– The minor number
– The micro number (patch number)
There is the fourth number, sometimes applied
after a dash is genarally the patch level , applied by
kernel maintainers
Ex : 2 . 4 . 7 - 10

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Kernel Version Numbering

Kernel version numbering is very structured :


– The minor number is even = stable version
– The minor number is odd = development ver.
– A patch constitutes a more precise measurement
of the kernel version. All patchs to the kernel
are cumulative. You simply have to obtain and
apply the latest patch for the kernel to be sure
you have the most up-to-date patched support
To find out what kernel you are running :
# uname -r
SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Recent Kernel Changes

There are many changes from 2.2 to 2.4


– Itanium and X86-64 AMD Hamer CPU support
– Improve PnP/hot swappable device regconition
– Journaling file systems : ext3, ReiserFS, ..
–…

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Preparing For The New Kernel

See
/usr/src/linux/Documentation/Changes
Software tools
The source tree (source code)
Apply patches to the kernel source code

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Software Tools

make : determines which pieces of a large program


need to be recompiled and compile them. It executes
commands in Makefile (sometime named makefile)
to update programs or module components
C/gcc : C compiler integrated into gcc
binutils: a collection of binary utilities :
gas(assembler), ld(likner), nm, ranlib, objdump, …

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
The Source Tree

Kernel source released as a zipped tar file,


extension of .tar.gz or .tar.bz2
Ex: linux-2.4.19-16.tar.gz
You should NEVER unpack your kernel sources
directly into /usr/src/linux
# tar xzfv linux-2.4.19-16.tar.gz –C /usr/src

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Apply patches to kernel source

A patch file is editing instructions to change one set


of files into new version of the files Ex: patch-2.4.19-
16-1-acl.gz
Steps to patch :
# ln –s /usr/src/linux-2.4.19-16 /usr/src/linux
# cp patch-2.4.19-16-1-acl /usr/src/linux
# cd /usr/src/linux
# cat patch-2.4.19-16-1-acl | patch –p1

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Customize & Install New Kernel

There are many possible make targets in the Linux


kernel Makefile that can be used to build kernel :
make dep Build a list of all kernel deps
make clean Remove old binaries and .o files
make zlilo Make a compressed vmlinuz
image and update LILO
make zImage Make a simple compressed image
make bzImage Build an image compressed with gzip

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
General Procedure to build kernel

•Step 1: Configure kernel’s parameters and build it


– make config or make menuconfig or make
xconfig
– make dep, make clean, make bzImage

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
General Procedure to build kernel

•Step 2: Compile modules


make modules
•Step 3: Install modules
make modules_install
•Step 4: Install kernel
make install
•Step 5: Check boot loader configuration
•Step 6: Backup file .config

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
make menuconfig Interface

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
make xconfig Interface

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Kernel Default Option with rdev

With rdev or its new name rootflags , you can set


default option appended to your new kernel image
without add them to /etc/lilo.conf
( See #man rdev for more information )

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Kernel Modules

insmod Install & binding a module to kernel.You can customize


module loadtime parameters in /etc/modules.conf or /etc/conf.modules
rmmod Unload a module from kernel
lsmod List currently loaded modules in kernel
modinfo Details about a module’s description
genksyms Generates symbol version information
modprobe Load a set of modules either a single module, a stack of
dependent modules or all modules that are marked with a specified tag
depmod Build a relationship table for modules that are required of
running kernel.You can put it in start-up script and run depmod –a
( Package : modutils )

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Building a Monolithic Kernel

If you build all supports directly into kernel, the


new kernel referred monolithic kernel
In kernel configuration, a “Y” answer for an
option means to build that option into the kernel
(monolithic); a “N” means exclude and “M” means
to build as a module.
You can omit make modules and make
modules_install when building a new kernel

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Boot Loader Features & Config
LILO (Linux Loader)
How to install ?
– Install LILO manually from the packet
– Let your Linux automatically install LILO
Where to install ? – first 1024 logical cylinders
– On a diskette
– In the boot sector of a primary or logical Linux
partition on the first harddisk
– In the Master Boot Record
You must run /sbin/lilo to update the configuration in
file /etc/lilo.conf
SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
LILO Configuration File

[root@lpi linux-2.4]# more /etc/lilo.conf


timeout=50
default=linux
boot=/dev/hda
root=/dev/hda1
message=/boot/message
image=/boot/vmlinuz-2.4.7-10
label=linux
read-only

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
Using LILO to Test a New Kernel

Make new entry in /etc/lilo.conf for your new


kernel :

image=/boot/vmlinuz-2.4.19-16
label=My New Kernel
read-only
Run /sbin/lilo –v command *
Boot with new kernel and observe

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
LILO and Boot Options

LILO command options


See #man lilo
Boot options
See #man lilo.conf and go to
“KERNEL OPTIONS” category

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
GRUB (GRand and Unified nified Bootloader)

•GRUB can boot multiple OS and quickly gaining popularity, may


soon replace LILO
•How to install ?
– Install GRUB manually
– Let your Linux automatically install GRUB
•Where to install ? – first 1024 logical cylinders
– On a diskette
– In the boot sector of a primary or logical Linux partition on
the first harddisk
– In the Master Boot Record
• You DON’T need to run /sbin/grub to update the configuration
in file /etc/grub.conf

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102
LOADLIN

•It’s a MS-DOS program that can launch a Linux


kernel from DOS prompt.This is very useful if you
have hardware that relies on MS-DOS driver.

SAIGONLAB 83 Nguyễn
69-3 ThịThi
Nguyen Nhỏ,Nho,
P9, Q.Tân Bình, Tp.Tp.
P9, Q.TBinh, HCMHCM LPI 102

You might also like