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 ha
Trang 2 Demonstrate new kernel preparation
Recompile and install a kernel
Configure LILO to use a new kernel
Trang 3 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
• Device drivers can be built as external modules to the kernel
Trang 4 Kernel Version Numbering
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
Trang 5 Kernel Version Numbering
- 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
# uname -r
Trang 6 Recent Kernel Changes
- Itanium and X86-64 AMD Hamer CPU support
- Improve PnP/hot swappable device regconition
- Journaling file systems : ext3, ReiserFS,
- …
Trang 7 The source tree (source code)
Apply patches to the kernel source code
Trang 8 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, …
Trang 9 The Source Tree
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
# mkdir /usr/src/linux-2.4.19-16
# tar xzfv linux-2.4.19-16.tar.gz –C
/usr/src/linux-2.4.19-16
Trang 10 The Source Tree
Subdirectories in the source tree : /usr/src/linux-2.4.19-16/
Documentation arch
drivers fs
include init
ipc
kernel lib
mm modules net
scripts
This is the structure that most kernel sources will follow
Trang 11 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 -pl
Trang 12 Customize & Install New Kernel
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 *
image and update LILO
make zImage Make a simple compressed image
make bzImage Build an image compressed with
gzip *
Trang 13 General Procedure to build kernel
Step 1: Configure kernel’s parameters and build it
xconfig
- make dep, make clean, make bzImage
Step 2: Copy new kernel from arch/i386/boot/
bzImage to /boot/vmlinuz-2.4.19-16
Step 3: Copy Sytem.map to
/boot/System.map-2.4.19-16
Trang 14 General Procedure to build kernel
Step 4: Copy config to
/boot/config-2.4.19-16
Step 5: Type make module
Step 6: Type make module_install
Step 7: Edit /etc/lilo.conf to make an new
entry to your new kernel
Trang 17customize module loadtime parameters in
/etc/modules.conf or /etc/conf.modules
a stack of dependent modules or all modules that are marked with a specified tag
required of running kernel.You can put it in
start-up script and run depmod –a
( Package : modutils )
Trang 18 Building a Monolithic 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.
modules_install when building a new kernel
Trang 19 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
Trang 20 LILO Configuration File
[root@lpi linux-2.4]# more /etc/lilo.conf
Trang 21 Using LILO to Test a New Kernel
your new kernel :
…
image=/boot/vmlinuz-2.4.19-16
label=My New Kernel read-only
Trang 22 LILO and Boot Options
See #man lilo
See #man lilo.conf and go to
“KERNEL OPTIONS” category
Trang 23 Demonstrate new kernel preparation
Recompile and install a kernel
Configure LILO to use a new kernel