[分享]内核编译完整步骤(可用,已试过)

其它Linux/Unix/BSD/OSX等发行版讨论
回复
wyylling
帖子: 51
注册时间: 2008-01-01 22:30
送出感谢: 0
接收感谢: 0
联系:

[分享]内核编译完整步骤(可用,已试过)

#1

帖子 wyylling » 2008-08-19 10:19

步骤:在www.kernal.org的官网上下载自己需要的内核,解压的步骤就省了吧,这个相信使用linux的人都会

1.我下载的是2.6.24的核,解压后的目录为linux-2.6.24。

cd linux-2.6.24若之前编译过内核,需要用命令

sudo make mrproper 清理一下

2.Now you can start kernel configuration by typing any one of the command:

$ make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.

$ make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop

$ make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.



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.



3.Compile kernel

Start compiling to create a compressed kernel image, enter:

$ make

Start compiling to kernel modules:

$ make modules

Install kernel modules (become a root user, use su command):

$ su -

# make modules_install

4.Install kernel

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:



System.map-2.6.24

config-2.6.24

vmlinuz-2.6.24

5.Create an initrd image

Type the following command at a shell prompt:

# cd /boot

# mkinitramfs -o initrd.img-2.6.24 2.6.24

initrd.img-2.6.24 表示initrd images,后一个2.6.24是的位置是在/lib/modules目录下

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.

6. Modify Grub configuration file - /boot/grub/menu.lst

Open file using vi:

# vi /boot/grub/menu.lst

title kernel 2.6.24 Default

root (hd0,2)

kernel /boot/vmlinuz root=/dev/hdb3 ro

initrd /boot/initrd.img-2.6.24

savedefault

bootRemember to setup correct root=/dev/hdXX device. Save the file. If you think editing and writing all lines by hand is too much for you then try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type command:

# update-grub

若仅仅用命令update-grub在menu.lst不会出现initrd /boot/initrd.img-2.6.24的,若无initrd的映像文件,该内核是不会启动,会出现错误,无法启动新内核。

7.computer and boot into your new kernel

Just issue reboot command:

# reboot
回复

回到 “其它类Unix OS发行版”