新手上路
三星級會員
- 舊站積分
- 2319
- 舊站發表文章數
- 826
|
樓主 |
發表於 2011-5-3 16:06:30
|
顯示全部樓層
Arch Linux 深入敵區之核心精簡大作戰(ck)
本篇對初學者是一項嚴格考驗, 請做好接受失敗與挫折的心理準備!
***核心套件***
Kernel26-ck
https://wiki.archlinux.org/index.php/Kernel26-ck
這是一個目前在 Arch AUR 裡面相當熱門的一個kernel套件, 最大特色是幫你整合好了 BFS 等補丁(patch).
BFS (Brain Fuck Scheduler) 簡介,Linux 桌面的極速未來?
http://linuxtoy.org/archives/bfs ... desktop-kernel.html
BFS, 有人說比RT更適合桌面系統!?
我只知道他目前是我所有版本裡面最好聽的… (2011,5,5現在,看何時推翻這句話!)
***初級安裝***
下載 Kernel26-ck 套件位置 ,
目前版本: kernel26-ck 2.6.38.5-1
http://aur.archlinux.org/packages.php?ID=32877
找到 Tarball :: PKGBUILD
在Tarball上按右鍵Save Link as ...(另存新檔)
開啟檔案管理員找到下載的 kernel26-ck.tar.gz, 按右鍵解壓縮 Extract Here..並輸入以下指令開始安裝
編譯核心是很花時間的過程, 建議先開啟BIOS的cpu和HT為auto,以加速編譯速度
(完全以預設值編譯如果在舊電腦可能要花2~3小時, 目前我精簡之後好像要十幾分鐘吧)
[root@BYOB kernel26-ck]# makepkg -s --asroot
-s 檢查相依性並自動下載相關檔案 (第二次以後編譯時應可不必加此參數)
--asroot 允許以root身份執行
第一次執行會開始下載所需檔案
100%[++++=============================>] 74,739,098 118K/s in 9m 53s
如果跟我一樣突然停在這裡不動, Ctrl+C 結束跳出
再執行一次相同指令, 下載過的檔案第二次以後就不會再下載了.
[root@BYOB kernel26-ck]# makepkg -s --asroot (按箭頭往上方向鍵重複上一個指令即可)
繼續開始他就會一路幫您自動下載檔案, 解壓縮, 打補丁, 編譯核心及編譯模組完成. (ARCH 就是這麼簡單!)
(編譯過程可能會出現一些 warning, 先不用管他, 結果比較重要!)
***進階選項***
當然我們這裡不是要他以預設值一路搞到底, 接下來重點就是教您如何從中編輯自訂參數完成最佳化cat需求.
開始前先打開編輯 PKGBUILD 這個檔案,(注意你的路徑可能跟我不一樣)
[root@BYOB kernel26-ck]# leafpad /home/kernels/kernel26-ck/PKGBUILD
Patch and Build Options
###############################################################################################
_makenconfig="n" # nconfig option
_localmodcfg="n" # make localmod config - compile ONLY probed modules - see notes below!
_use_current="n" # use the current kernel's .config file - see notes below!
_BFQ_patches="n" # add BFQ patches for the BFQ I/O scheduler
################################################################################################
修改執行選項如下:
###############################################################################################
_makenconfig="y" # nconfig , 最重要的config參數編輯選單, 同等舊版的 menuconfig .
_localmodcfg="y" # 執行localmodconfig 自動幫你將目前電腦運行中的模組選上,初步過濾沒用到的
_use_current="n" # 直接拿運行中的kernel參數來用, 如果用的是一般的kernel版那就不用選了.
_BFQ_patches="y" # 較新的 I/O scheduler, 雖然已經決定用noop及deadline, 但我還是先打上!
################################################################################################
***開始編譯***
[root@BYOB kernel26-ck]# makepkg -s --asroot
...(略)
==> Running Steven Rostedt's make localmodconfig now
...(略)
Use ext4 for ext2/ext3 file systems (EXT4_USE_FOR_EXT23) [Y/n/?] (NEW) n (y 跟 n 隨便啦, 反正馬上就會進去選單編輯了)
之後會跑出這個參數設定選單
.config - Linux/x86_64 2.6.38 Kernel Configuration
┌── Device Drivers ──────────────────────────────────────────────┐
│ │
│ < > Connector - unified userspace <-> kernelspace linker ---> │
│ < > Memory Technology Device (MTD) support ---> │
│ <M> Parallel port support ---> │
│ -*- Plug and Play support ---> │
│ Block devices ---> │
│ Misc devices ---> │
│ <M> ATA/ATAPI/MFM/RLL support (DEPRECATED) ---> │
│ SCSI device support ---> │
│ <M> Serial ATA and Parallel ATA drivers ---> │
│ Multiple devices driver support (RAID and LVM) ---> │
│ < > Generic Target Core Mod (TCM) and ConfigFS Infrastructure ---> │
│ Fusion MPT device support ---> │
│ IEEE 1394 (FireWire) support ---> │
│ < > I2O device support ---> │
│ Macintosh device drivers ---> │
│ -*- Network device support ---> │
│ ISDN support ---> │
│ < > Telephony support ---> │
│ Input device support ---> │
│ Character devices ---> │
│ {M} I2C support ---> │
│ SPI support ---> │
│ PPS support ---> │
│ -*- GPIO Support ---> │
│ < > Dallas's 1-wire support ---> │
│ {*} Power supply class support ---> │
│ {*} Hardware Monitoring support ---> │
│ {*} Generic Thermal sysfs driver ---> │
│ Watchdog Timer Support ---> │
│ Sonics Silicon Backplane ---> │
│ -*- Multifunction device drivers ---> │
│ [ ] Voltage and Current Regulator Support ---> │
│ <M> Multimedia support ---> │
│ │
│ │
└F1Help─F2Sym Info─F3Insts─F4Config─F5Back─F6Save─F7Load─F8Sym Search─F9Exit───────────────┘
基本上用方向鍵選擇,enter確認,ESC回上一層,要編譯進核心的打y, 要編譯成模組的打m,F6存檔,F9離開 並繼續編譯
這選單裡含子選單的項目Total估計有幾百項吧!
安啦, 有些子選項看不喜歡就直接全砍了, 然後就出事情了, 哈 !
欲練神功, 必先自宮 !
為了對抗外星人, 直覺就是把 Networking support 給全閹掉, 但這個造就我痛苦的2個多禮拜!
幾個優化重點:
1. 安全性相關全砍
2. debug相關全砍
3. 網路全砍只留一項 Unix domain sockets (雖然不上網但仍有些程式會用到)
4. 電源管理只保留acpi本項裡的Power Management Timer Support, 其他子選項全砍
5. 雖然沒有SCSI設備 但這項一定要選 <*> SCSI disk support
...
這裡有幾篇選項解說可以參考看看,有些中文解說還是看不懂就Google一下囉!
因核心版本關係可能有些不一樣,先有個概念,等我有空再來整理一版! (網路上大家都抄來抄去, For 終極貓 的還沒看到)
鳥哥的 Linux 私房菜 - Linux 核心編譯與管理
http://linux.vbird.org/linux_basic/0540kernel/0540kernel-fc4.php
請在鳥哥這裡瞭解linux開機流程, 因為linux為二段式開機,與開機有關的東西必須編譯成模組...
Linux 內核編譯 —— make localmodconfig 簡化內核配置流程
http://blog.163.com/vic_kk/blog/static/4947052420108132423450/
實戰linux內核精簡 (作者:debug-sai)
http://debug-sai.blogbus.com/logs/47865842.html
Linux 2.6.36內核優化指南 (作者:Ken Wu)
http://kenwublog.com/docs/linux-kernel-2-6-36-optimization.htm
***安裝封包***
成功編譯完成後會產生兩個封包檔, 可用pacman直接安裝. (真是方便!)
# pacman -U kernel26-ck-headers-2.6.38.5-1-x86_64.pkg.tar.xz
# pacman -U kernel26-ck-2.6.38.5-1-x86_64.pkg.tar.xz
完成後會在/boot下面多出4個檔案:
# ls -l /boot
-rw-r--r-- 1 root root 1836123 May 7 17:01 kernel26-ck-fallback.img
-rw-r--r-- 1 root root 1500337 May 7 17:01 kernel26-ck.img
-rw-r--r-- 1 root root 851696 May 7 16:38 System.map26-ck
-rw-r--r-- 1 root root 1133696 May 7 16:38 vmlinuz26-ck
***修改選單***
參考後面第三篇 (RealTime實時核心)
***面對失敗***
如果編譯失敗或開機失敗, 記下錯誤訊息, 求助你最好的朋友google!
第二次編譯時,不需要重新下載檔案, 但要刪除以下的東西:
pkg 目錄全部刪除
src 目錄全部刪除
kernel26-ck-headers-2.6.38.5-1-x86_64.pkg.tar.xz 檔案刪除
kernel26-ck-2.6.38.5-1-x86_64.pkg.tar.xz 檔案刪除 |
|