「Learning Linux Kernel」- 初识内核源码

  CREATED BY JENKINSBOT

获取内核源码

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

git pull

源码目录结构

# tree -L 1 --dirsfirst
.
├── arch -------------------------- Architecture-specific source
├── block ------------------------- Block I/O layer
├── crypto ------------------------ Crypto API
├── Documentation ----------------- Kernel source documentation
├── drivers ----------------------- Device drivers
├── firmware ---------------------- Device firmware needed to use certain drivers
├── fs ---------------------------- The VFS and the individual filesystems
├── include ----------------------- Kernel headers
├── init -------------------------- Kernel boot and initialization
├── ipc --------------------------- Interprocess communication code
├── kernel ------------------------ Core subsystems, such as the scheduler
├── lib --------------------------- Helper routines
├── mm ---------------------------- Memory management subsystem and the VM
├── net --------------------------- Networking subsystem
├── samples ----------------------- Sample, demonstrative code
├── scripts ----------------------- Scripts used to build the kernel
├── security ---------------------- Linux Security Module
├── sound ------------------------- Sound subsystem
├── tools ------------------------- Early user-space code (called initramfs)
├── usr --------------------------- Tools helpful for developing Linux
├── virt -------------------------- Virtualization infrastructure
├── COPYING
├── CREDITS
├── Kbuild
├── MAINTAINERS
├── Makefile
├── README
└── REPORTING-BUGS

编译安装内核

第一步、配置内核

方法一、生成默认配置:

make defconfig

方法二、根据需要,配置内核(以下命令是等价的,操作方式不同):

# make config
# make gconfig
make menuconfig

方法三、将旧的配置,应用于当前源码:

zcat /proc/config.gz > .config
make oldconfig

当配置结束后,将生成 .config 文件。

第二步、编译内核

make

System.map:符号对照表;

第三步、安装内核

安装内核镜像文件的方式,取决于引导加载程序

安装内核模块,可以执行如下命令:

make modules_install