[轉貼]Debian-Kernel-Compile-Howto

常言道:『飲水思源』,在 Open Source 的世界裡,我們常常需要別人的幫助,但是在您有所心得的時候請記得分享給大家,『幫助人是快樂的喔』。歡迎您在使用 debian 的過程中的任何心得分享給大家。

[轉貼]Debian-Kernel-Compile-Howto

文章moto » 週二 3月 02, 2004 12:28 pm

Data from : http://www.projektfarm.com/en/support/h ... mpile.html


Debian-Kernel-Compile-Howto


Version 1.0
Author: Falko Timme <falko [dot] timme [at] projektfarm [dot] de>
Last edited 12/06/2003


In some cases you might want to compile your own kernel that suits your needs better than the standard kernel that comes with your distribution. I will describe how to do this on a Debian machine.

Be aware that there is some risk in doing so! For example, it could happen that your machine does not boot properly after you have installed the new kernel so you might be forced to boot from a rescue CD to repair your system. You have been warned! This document comes without warranty of any kind!



Kernel-Compile-Howto

First login to your Debian machine on the command line as root. Install the prerequisites that we need to compile the new kernel:
代碼: 選擇全部
apt-get install kernel-package ncurses-dev fakeroot wget bzip2

Then go to /usr/src:
代碼: 選擇全部
cd /usr/src

Then get the latest Linux kernel source (or the kernel source you need) from http://www.kernel.org/pub/linux/kernel/v2.4/:
代碼: 選擇全部
wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.23.tar.bz2

Unpack the kernel sources:
代碼: 選擇全部
tar xjf linux-2.4.23.tar.bz2

cd linux-2.4.23/

It is normally a good idea to take the configuration of your existing (working!) kernel as a starting point for the configuration of your new kernel. Usually the current kernel configuration is saved in a file under /boot, e.g. /boot/config-2.4.18-bf2.4. We will load this configuration and then do the changes we desire (e.g. add quota support, iptables support, etc.).
代碼: 選擇全部
make menuconfig

Select Load an Alternate Configuration File and enter the location of the configuration file of your current kernel:

圖檔

圖檔

The configuration of your current kernel will be loaded, and you can now browse through the menu and change the configuration to suit your needs. When you are finished, save your new kernel configuration:

圖檔

Then run the following commands:
代碼: 選擇全部
make dep
make-kpkg clean
fakeroot make-kpkg --revision=custom.1.0 kernel_image

If the compilation stops with an error, run
代碼: 選擇全部
make clean

and then re-run the previous commands starting with
代碼: 選擇全部
make menuconfig

Change the kernel configuration where the error occurs (e.g., the compilation often gives back errors for some WAN modules, so leave them out if you do not need them). If no error occurs you will find the new kernel as a Debian package called kernel-image-2.4.23_custom.1.0_i386.deb under /usr/src.
代碼: 選擇全部
cd ../

Now you can install the new kernel by doing the following:
代碼: 選擇全部
dpkg -i kernel-image-2.4.23_custom.1.0_i386.deb


We are almost finished now. Reboot your machine:
代碼: 選擇全部
shutdown -r now

and if everything is ok your machine should come up with the new kernel. You can run
代碼: 選擇全部
uname -a

to verify that. Good luck!
歡迎你來到MOTO學園一起討論Debian相關問題。
在post問題前可先別忘記了以下的步驟:
1:翻一下/usr/share/doc/中是否已經有解答了?
2:閱讀一下無痛起步是否已經提到了?
3:找一下google予以解答?
4:善用學園中的"搜尋"功能,往往答案就在裡面窩。
頭像
moto
摩托學園站長
摩托學園站長
 
文章: 2808
註冊時間: 週二 9月 03, 2002 3:37 am
來自: 台北

回到 share

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客