linux 学习笔记-核心编译
时间:2009-07-18 来源:mingwjj
1. 核心的版本與下載
make menuconfig:
利用類似選單模式的方式來進行核心參數的挑選,好處是,他是純文字模式的! 不需要啟動 X Window ,還可以遠端登入進行核心參數的挑選!真方便!
- http://www.kernel.org/
- 交大資科:ftp://linux.cis.nctu.edu.tw/kernel/
- 義守大學:http://ftp.isu.edu.tw/pub/Linux/kernel/
make menuconfig:
利用類似選單模式的方式來進行核心參數的挑選,好處是,他是純文字模式的! 不需要啟動 X Window ,還可以遠端登入進行核心參數的挑選!真方便!
- Code maturity level options(核心的 code 開發維護)
- General setup 這個項目則是關於核心的一般設定,包括核心的附加版本資訊等等,都可以在這裡設定。
- Loadable module support 還記得我們上頭曾經提過模組這個玩意兒吧!如果你要核心能夠支援模組即時載入某些核心功能的話, 那麼這裡面的設定就顯的很重要了!因為他涉及是否支援模組載入啊!
- Processor type and features 這個就與您的 CPU 有關啦!我的主機裝備的是 P-III 的 CPU ,所以就選擇相關的即可。 你要依據你自己的主機來設計喔!不要胡亂選擇啊!
- Power management options (ACPI, APM) 這部分則是電源管理
- Bus options (PCI, PCMCIA, EISA, MCA, ISA) 這個項目則與匯流排有關啦!分為最常見的 PCI,還有筆記型電腦常見的 PCMCIA 插卡啊!
- Executable file formats 這裡必須要勾選才行喔!因為是給 Linux 核心運作執行檔之用的資料! 除了第一項必須要編成核心功能之外,其他兩項是可以編譯成為模組的啦!
- Networking 這個項目是相當相當相當 * n 重要的選項,因為他還包含了防火牆相關的項目! 就是未來在伺服器篇會談到的防火牆 iptables 這個資料啊!所以,千萬注意了!
- Device Drivers 這個是所有硬體裝置的驅動程式庫!哇!光是看到裡面這麼多內容,鳥哥頭都昏了~ 不過,為了您自己的主機好,建議你還是得要一個項目一個項目的去挑選挑選才行~ 這裡面的資料就與您主機的硬體有絕對的關係了!
- File systems 檔案系統的支援也是很重要的一項核心功能!因為如果不支援某個檔案系統, 那麼我們的 Linux kernel 就無法認識,當然也就無法使用啦!例如 Quota, NTFS 等等特殊的 filesystem 。
- Security options 這一部份與安全性比較有關。幾乎保留預設值即可,仔細注意一下 SELinux 的項目, 該項目是美國國家安全局發展的 Linux 細部安全維護控制項目,需要勾選才行!
- Cryptographic options 這部份則是加密參數的設定。一般我們使用的帳號密碼登入,利用的就是 MD5 這個加密機制,要讓核心有支援才行啊!幾乎所有的項目都給他做成模組即可! 不過 MD5 與 SHA1 必須要直接由核心支援比較好!
- 取用舊資料與儲存設定
Load an Alternate Configuration File
Save Configuration to an Alternate File
3.核心的編譯與安裝
1).編譯的流程
[root@linux linux-2.6.14.2]# make clean
# 將以前曾經進行過的 *.o 檔案刪除掉,這樣比較不會產生新舊版本的誤差!
[root@linux linux-2.6.14.2]# make bzImage
# 製作出核心檔案!這個重要!過程很長啊!而且那個是大寫的 I 喔!
[root@linux linux-2.6.14.2]# make modules
# 製作出模組相關的檔案!
2).模組安裝
[root@linux ~]# cd /lib/modules
[root@linux modules]# mv 2.6.14.2 2.6.14.2.old
#如果编译同一版本的核心,要把旧的改名呦
[root@linux linux-2.6.14.2]# make modules_install
3).製作 initrd 這個初始化虛擬磁碟
[root@linux ~]# mkinitrd /boot/initrd_2.6.14.2 2.6.14.2
# 此時會產生新檔案 /boot/initrd_2.6.14.2 喔!
# 且這個動作需要在安裝好模組之後進行才會生效!
4). 移動新核心到 /boot 裡面去:
[root@linux ~]# cp /usr/src/linux-2.6.14.2/arch/i386/boot/bzImage /boot/vmlinuz-2.6.14-2
# 就一般的習慣而言,鳥哥建議您將核心檔名設定成以 vmlinuz 為首的名稱,
[root@linux ~]# cp /usr/src/linux-2.6.14.2/System.map /boot/System.map-2.6.14-2
5). 修改 grub 設定檔
[root@localhost ~]# vim /boot/grub/menu.lst
1 # grub.conf generated by anaconda
2 #
3 # Note that you do not have to rerun grub after making changes to this file
4 # NOTICE: You have a /boot partition. This means that
5 # all kernel and initrd paths are relative to /boot/, eg.
6 # root (hd0,6)
7 # kernel /vmlinuz-version ro root=/dev/sda10
8 # initrd /initrd-version.img
9 #boot=/dev/sda
10 default=3
11 timeout=5
12 splashimage=(hd0,6)/grub/splash.xpm.gz
13 hiddenmenu
14 title CentOS (2.6.20.18)
15 root (hd0,6)
16 kernel /vmlinuz-2.6.20.18 ro root=LABEL=/ rhgb quiet
17 initrd /initrd-2.6.18-128.e15.img
18 title CentOS-base (2.6.18-128.el5)
19 root (hd0,6)
20 kernel /vmlinuz-2.6.18-128.el5 ro root=LABEL=/ rhgb quiet
21 initrd /initrd-2.6.18-128.el5.img
22 title XP
23 rootnoverify (hd0,0)
24 chainloader +1
相关阅读 更多 +