building a custom kernel(翻译+精简)

原始文章url: … ernel.html

1.uname -r 查看你的linux核心版本号

2.mkbootdisk --device /dev/fd0 2.4.x
(where 2.4.x is the full version of your kernel such as 2.4.18-7.95).

3.rpm -q kernel-source
确认linux核心源码是否已经安装. /usr/src/linux-2.4
改变目录到/usr/src/linux-2.4 从现在开始所有的命令都是在这个目录中执行.

5.make mrproper

This will remove any configuration files along with the remains of
any previous builds that may be scattered around the source tree
If you already have an existing configuration file that works
(/usr/src/linux-2.4/.config) and you want to use, back it up to
a different directory before running this command and copy it
back afterward.

6.make menuconfig


[*] (built-in), [ ] (exclude), (module), or < > (module capable).

To use kmod (see Chapter 30 for details) and kernel modules you must
answer Yes to kmod support and module version (CONFIG_MODVERSIONS)
support during the configuration

7.make dep

8.make clean
to prepare the source tree for the build.


By default, /usr/src/linux-2.4/Makefile includes the word custom at the
end of the line beginning with EXTRAVERSION. Appending the string will
allow you to have the old working kernel and the new kernel, version 2.4.18-7.95custom,
on your system at the same time.

To give the kernel an “unique” name, you can also append the date to the end of the string

10.make bzImage

11.make modules

12.make modules_install
install the kernel modules (even if you did not build any). Make sure that you type the underscore (_).
This will install the kernel modules into the directory path /lib/modules/KERNELVERSION/kernel/drivers
(where KERNELVERSION is the version specified in the Makefile). In the example it would
be /lib/modules/2.4.18-7.95custom/kernel/drivers/.

13.make install

copy your new kernel and its associated files to the proper directories.
In addition to installing the kernel files in the /boot directory, this
command also executes the /sbin/new-kernel-pkg script that builds a new
initrd image and adds new entries to the boot loader configuration file.

If you have a SCSI adapter and you compiled the SCSI driver as a module or
if you built your kernel with ext3 support as a module (the default in Red Hat Linux),
the initrd image is required