Linux Kernel learning and compiling Linux kernel notes

Source: Internet
Author: User

For more information, see "learn while doing" by Zhejiang University Press.

Chapter 9 Linux kernel compilation experiment objective: to learn how to re-compile the Linux kernel and understand the differences between the Linux standard kernel and the released version. experiment content: compiling the Linux kernel is an operational experiment, you do not need to have a deep understanding of the source code in the kernel, nor do you need many programming skills. Tutorial guide: 1. Linux kernel: Learn about the Linux kernel and learn how to implement a modern operating system. The kernel is the core program of the operating system. It provides external core management calls for computer devices. Generally, the code running on the OS is divided into two parts: kernel space and user space. Generally, a program spans two spaces, namely, whether the program is in the kernel or user State. Core Management of computers mainly involves resource abstraction, resource allocation, and resource sharing. Linux is a single-core architecture. 2. find and download a kernel source code: We recommend you download www.kernel.org on the official website. You can view your Linux version by entering # uname-R under the terminal. Here, my system is centos, the kernel version is 2.6.18-164. el5. I will not download it here. Go directly to my Linux system and find the kernel location in/usr/src/kernels/2.6.18-164. el5-i6863. configure the kernel: Configuring the kernel is an opportunity to precisely control the new kernel functions. The configuration process also controls the binary images compiled into the kernel (loaded at startup ), these are the kernel modules to be loaded ). First, go to makelfile, modify extraversion, and change it to the kernel you need to configure. In order to keep the kernel source code tree in a State, it is necessary to use the command # Make mrproper to clear the configuration file and the previously generated. o file. # Make menuconfig to go to the text-based menu configuration interface. Of course, there are many other commands to enter this option, such as make xconfig, make gconfig, and make oldconfig. 4. Compile the kernel and modules: it takes about one hour to compile the kernel. The resulting binary Kernel File bzimage is under/usr/src/kernels/2.6.18-164. el5-i686/ARCH/i386/boot. If you select a module that can be loaded, you need to compile the module and use # Make modules, # Make modules_install5. understanding Linux kernel startup: Generally, when a Linux system is started, it reads the kernel image from the system/boot to the memory. Therefore, we need to put the image in/usr/src/kernels/2.6.18-164. el5-i686/ARCH/i386/boot compiled Kernel File bzimage and system. copy the map to/boot. You can also use the command # make install. 6. Apply the grub configuration Startup File: If you use grub to start Linux, You need to edit the/boot/GRUB/grub. conf file to modify the system boot file configuration. If the bzimage kernel is compiled, restart the host system. After completing all the experiments, # Make clean clears all temporary files. 7. Compile the shell script program for creating the Linux boot disk: four types: boot disk, root disk, boot/root disk, and utility disk. In fact, the possibility of using this method is getting smaller and smaller. 8. distribution directory of Linux source programs: the source code of Linux is structured in a tree. The core source code of the kernel is mainly in the kernel and arch <architecture type>/kernel, /arch is divided by the processor architecture, including arm, i386, and PowerPC. The following describes some important directories (1). Kernel Directory: Most of the files in this directory are kernel functions in the Linux kernel. The most important and important files are sched. C. In this file, the scheduler schedule is defined for each CPU to define the Run-ready queue, waiting queue, and Process Migration between CPUs. My personal understanding is how the most critical process scheduling in the kernel is implemented under this file. The process files include fork. C (create sub-process), exit. C (End Process), signal. C (signal control), and so on. (2) mm Directory: almost all memory management files are here, such as paging memory management and kernel memory distributor. Swapfile. c is the source program for managing swap files and devices. Page_io.c implements data transmission between the memory and the storage space. MMAP. C contains functions such as virtual space ing. (3) FS Directory: directory for file processing implementation. Many familiar system calls are hidden in the directory, such as exec. c, open. c, read_write.c, select. c, FIFO. c, fcntl. c. If you want to know the functions that the system calls to operate on files and the implementation of pipelines, you can take a look. (4) arch Directory: As mentioned earlier, all are architectures. (5) include directory: contains all the header files under the Linux source program (6). Net Directory: it is a C file directory related to the Linux network. And so on. There are also IPC, drivers, init, and so on ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.