Customize your kernel in Debian Lenny

准备:

首先,你需要安装Debian Lenny build kernel所需要的包,如下:

build-essential: essential package for building Debian packages: make, gcc, …

bzip2 : compress and decompress utilities for bz2 files.

libncurses5-dev: developer’s libraries and docs for ncurses.

git: distributed revision control system used by the linux kernel.

fakeroot: provide fakeroot environment for building package as non-root.

initramfs-tools: tool to build an initramfs (Debian specific).

kernel-package : tool to build linux kernel package (Debian specific)

module-assistant: tool to help build module packages (Debian specific)

dkms:

devscripts: helper scripts for debian package maintainer (debian specific)

linux-tree-2.6.* linux kernel source tree meta package

所有需要的package安装完成以后,就可以构建customized kernel。

linux-tree-2.6.*(我使用的是2.6.26)安装完成以后,在/usr/src下面,你会发现kernel-patches, linux-support等几个目录,以及linux-source-2.6.26.tar.bz2 源码包。

你可以将linux-source-2.6.26.tar.bz2源码包解压到你希望的位置,比如解压到/usr/src目录下,会创建/usr/src/linux-source-2.6.26.具体如下:

tar –xjvf linux-source-2.6.26.tar.bz2

然后cd到解压后源码的顶层目录:/usr/src/linux-source-2.6.26

cd /usr/src/linux-source-2.6.26

cat version.Debian

version Debian 文件存放当前debian linux source的版本和patch level。

所有patch存放在/usr/src/kernel-patches-/目录下

为了编译kernel最好先从/boot/config-$(uname -r) 当源码顶层目录

cp /boot/config-$(uname -r) .config

然后customize 你的kernel配置,通过make menuconfig 命令。

接下来执行make-kpkg clean

最好执行fakeroot make-kpkg  --append_to_version -amd64 --initrd --revision=1.0 kernel_image modules_image 编译你自己的kernel。

--append_to_version 选项用于指定suffix,等同于在kernel Makefile里德EXTRAVERSION 参数。

成功执行完成后,在当前目录的上一层目录会有编译好的新的linux kernel 的debian 安装包。

dpkg –i  linux-image*.deb

提示:可以通过设置export CONCURRENCY_LEVEL=NUM 其中NUM是你的CPU的数量,其效果等同于make –jNUM

指定kernel source code的源码级别

/usr/src/kernel-patches/all/2.6.26/apply/debian orig 可以unapply所有当前source code已经打的patch。

/usr/src/kernel-patches/all/2.6.26/apply/debian 2 为当前的source code打level 1和level 2 的patch

/usr/src/kernel-patches/all/2.6.26/unpatch/debian unpatch当前的linux source code

原文地址:https://www.cnblogs.com/yuboyue/p/2109844.html