1.编译内核步骤:
##download kernel from www.kernel.org
##解压内核,打相应补丁文件
1)tar jxvf linux-2.6.32 -C /usr/src/
2)cd /usr/src
3)patch -p1 < patch_file;
or
zcat file.patch.bz2 | patch -p1 -d linux
##配置,编译内核及一些你想动态加载的模块;
4)make mrproper;
5)make menuconfig;
6)make dep;
//7)make clean;
8)make bzImage;
9)make modules_install;
##配置启动文件-- Linux在系统引导后从/boot下读取内核映像到内存中,if我们想要用我们编译的内核,就要将其拷贝到/boot下。System.map文件记录了内核映像中的符号及其对应的地址。
10)cp /usr/src/linux/arch/i386/boot/zImage /boot/zImage-2.6.32;
11)cp /usr/src/linux/System.map /boot/System.map-2.6.32;
12)ln -sf /boot/System.map-2.6.32 /boot/System.map.
##修改引导配置
vi /etc/grub.conf
image=/boot/zImage-2.6.32
label=my_kernel_2.6.32
read-only
root=/dev/hda1 ##根据实际的linux的硬盘
##大功告成!:)
二、README:
- Make sure you have no stale .o files and dependencies lying around:
cd linux
make mrproper
You should now have the sources correctly installed.
SOFTWARE REQUIREMENTS
Compiling and running the 2.6.xx kernels requires up-to-date
versions of various software packages. Consult
Documentation/Changes for the minimum version numbers required
and how to get updates for these packages. Beware that using
excessively old versions of these packages can cause indirect
errors that are very difficult to track down, so don't assume that
you can just update packages when obvious problems arise during
build or operation.
BUILD directory for the kernel:
When compiling the kernel all output files will per default be
stored together with the kernel source code.
Using the option "make O=output/dir" allow you to specify an alternate
place for the output files (including .config).
Example:
kernel source code: /usr/src/linux-2.6.N
build directory: /home/name/build/kernel
To configure and build the kernel use:
cd /usr/src/linux-2.6.N
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel modules_install install
Please note: If the 'O=output/dir' option is used then it must be
used for all invocations of make.
- compiling the kernel with "Processor type" set higher than 386
will result in a kernel that does NOT work on a 386. The
kernel will detect this on bootup, and give up.
##模块在系统位于/lib/modules/x.y.z,在make modules前最好先备份/lib/modules目录。
##模块通常是一个.o的文件,可以lsmod看当前内核已经装载了那些模块。
##如果你想把编译的内核移植到另一个linux系统中,这个目录也必须移植到目标系统的相同位置。
- Do a "make" to create a compressed kernel image. It is also
possible to do "make install" if you have lilo installed to suit the
kernel makefiles, but you may want to check your particular lilo setup first.
To do the actual install you have to be root, but none of the normal
build should require that. Don't take the name of root in vain.
- If you configured any of the parts of the kernel as `modules', you
will also have to do "make modules_install".
-- nm vmlinux | sort | less
This will give you a list of kernel addresses sorted in ascending
order, from which it is simple to find the function that contains the
offending address. Note that the address given by the kernel
debugging messages will not necessarily match exactly with the
function addresses (in fact, that is very unlikely), so you can't
just 'grep' the list: the list will, however, give you the starting
point of each kernel function, so by looking for the function that
has a starting address lower than the one you are searching for but
is followed by a function with a higher address you will find the one
you want. In fact, it may be a good idea to include a bit of
"context" in your problem report, giving a few lines around the
interesting one.
三、了解你的PC硬件,用于make menuconfig
cat /proc/....;