Linux Kernel

23 390 0
Linux Kernel

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Linux Kernel The Saigon CTT The Saigon CTT  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 Saigon CTT  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 basic options : • Device drivers can be built directly into the kernel binary itself • Device drivers can be built as external modules to the kernel The Saigon CTT  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 : - 10 The Saigon CTT  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 The Saigon CTT  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, - … The Saigon CTT  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 The Saigon CTT  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 Saigon CTT  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 Saigon CTT  The Source Tree  Subdirectories in the source tree : /usr/src/linux-2.4.19-16/ Documentation kernel arch lib drivers mm fs modules include net init scripts ipc  This is the structure that most kernel sources will follow The Saigon CTT  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 The Saigon CTT  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 * The Saigon CTT  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 The Saigon CTT  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 The Saigon CTT  make menuconfig Interface The Saigon CTT  make xconfig Interface The Saigon CTT  Kernel Modules 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 ) insmod The Saigon CTT  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 The Saigon CTT  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 The Saigon CTT  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 ... 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. .. /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 Saigon CTT  The Source Tree  Subdirectories in the source tree : /usr/src /linux- 2.4.19-16/ Documentation kernel. .. /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 The Saigon CTT  Customize & Install New Kernel

Ngày đăng: 24/06/2013, 01:25

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan