以前编过好几次内核都没成功,这次终于通过了,虽然还有些小问题。
Visit http://kernel.org/ and download the latest source code. File name would be linux-x.y.z.tar.bz2, where x.y.z is actual version number. For example file inux-2.6.25.tar.bz2 represents 2.6.25 kernel version. Use wget command to download kernel source code:
$ cd /tmp
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-x.y.z.tar.bz2
Note: Replace x.y.z with actual version number.
//**就是在网站上下载最新版本或者需要版本的内核源代码以前编过好几次内核都没成功,这次终于通过了
Type the following command:
# tar -xjvf linux-2.6.25.tar.bz2 -C /usr/src
# cd /usr/src
//**解压到/usr/src
Before you configure kernel make sure you have development tools (gcc compilers and related tools) are installed on your system. If gcc compiler and tools are not installed then use apt-get command under Debian Linux to install development tools.
# apt-get install gcc
Now you can start kernel configuration by typing any one of the command:
For example make menuconfig command launches following screen:
$ make menuconfig
You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.
//**gcc一般在安装fedora的时候已经装了,好像xconfig和gconfig都用不了,不晓得为什么。
Start compiling to create a compressed kernel image, enter:
$ make
Start compiling to kernel modules:
$ make modules
$ su -
# make modules_install
//**
编译内核
So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install
It will install three files into /boot directory as well as modification to your kernel grub configuration file:
我编的时候没生成config文件,可能是配置内核的时候没做什么改动都用到默认配置,不过也没关系,系统照样跑起来了
Type the following command at a shell prompt:
# cd /boot
# mkinitrd -o initrd.img-2.6.25 2.6.25
initrd images contains device driver which needed to load rest of the operating system later on. Not all computer requires initrd, but it is safe to create one.
//**系统里面找不到mkinitrd命令,直接把原有内核到img文件改个名字也可以用,或者安装mkinitrd:"yum install mkinitrd",img好像是引导时分配内存的吧
Open file using vi:
# vi /boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.25 Default root (hd0,0) kernel /boot/vmlinuz root=/dev/hdb1 ro initrd /boot/initrd.img-2.6.25 savedefault boot
Remember to setup correct root=/dev/hdXX device. Save and close the file. If you think editing and writing all lines by hand is too much for you, try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type the command:
# update-grub
Neat. Huh?
Just issue reboot command:
# reboot
For more information see: