Linux Kernel

Chia sẻ bởi Nguyễn Việt Vương | Ngày 29/04/2019 | 88

Chia sẻ tài liệu: Linux Kernel thuộc Bài giảng khác

Nội dung tài liệu:

Linux Kernel
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
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
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
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
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, ..

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
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, …
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
# 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
The Source Tree
Subdirectories in the source tree : /usr/src/linux-2.4.19-16/
This is the structure that most kernel sources will follow.
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
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 *
General Procedure to build kernel
Step 1: Configure kernel’s parameters and build it
- make config | make menuconfig | make 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
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

image=/boot/vmlinuz-2.4.19-16
label=My New Kernel
read-only
Step 8: Execute /sbin/lilo -v
make menuconfig Interface
make xconfig Interface
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 )
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 )
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
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
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
root=/dev/hda5
...
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
LILO and Boot Options
LILO command options
See #man lilo

Boot options
See #man lilo.conf and go to “KERNEL OPTIONS” category
GRUB (GRand Unified 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
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.
Summary
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
* Một số tài liệu cũ có thể bị lỗi font khi hiển thị do dùng bộ mã không phải Unikey ...

Người chia sẻ: Nguyễn Việt Vương
Dung lượng: | Lượt tài: 4
Loại file:
Nguồn : Chưa rõ
(Tài liệu chưa được thẩm định)