2015年3月20日 星期五

15/03/16 行前準備

一、行前準備:

1. 安裝工具介紹: X86/ARM Toolchain

1.1 執行底下指令:

# apt-get install gcc cpp g++

1.2 安裝完後來驗證 gcc/cpp/g++ 之版本

gcc -v
cpp -v
g++ -v

其它工具,例如 nasm 或是 java 等暫跳過,等遇到的時候再來安裝。

2. 使用 x86 toolchai 來升級 Linux 核心

2.1 核心升級,請安裝以下套件:

sudo apt-get install kernel-package libncures5-dev bzip2 xz-utils

2.2下載核心並建立連結

wget ftp://120.117.72.71/advlinux/linux-3.14.34.tar.xz
su
tar xfva linux-3.14.34.tar.xz -C /usr/src
ln -s /usr/src/linux-3.14.34 linux
cd linux

2.3 編譯 Linux 核心

a. 選單 .config 設定 
先至原始核心內複製基礎 config 檔案 
cp /boot/config-3.2.0-4-amd64 /usr/src/linux/.config

b. 設定選單 (於 /usr/src/linux 目錄下)
make menuconfig

可以使用幾個指令查看目前硬體,依硬體設備及需求來設定屬於自己的核心參數:
lspci -v
lsusb
cat /proc/cpuinfo

以下是我的電腦設定,以南臺 P503 教室電腦為例:
→ General setup → Kernel compression mode (XZ)

→ Processor type and features → Processor family (Core 2/newer Xeon)

→ Power management and ACPI options → CPU Frequency scaling →  Default CPUFreq governor (ondemand)

→ Power management and ACPI options → CPU Frequency scaling → x86 CPU frequency scaling drivers → [ ] Intel P state control

→ Power management and ACPI options → CPU Frequency scaling → x86 CPU frequency scaling drivers → <  > AMD...

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → Core Netfilter Configuration →  Netfilter nf_tables...

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → Core Netfilter Configuration →  ... match support

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → Core Netfilter Configuration →  Netfilter nf_tables ...

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → Core Netfilter Configuration →  Netfilter ....

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → IP: Netfilter Configuration →  IPv4 nf_tables ...

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → IP: Netfilter Configuration →  IPv4 NAT

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → IPv6: Netfilter Configuration →  IPv6 nf_tables ...

→ Networking support → Networking options → Network packet filtering framework (Netfilter) → IPv6: Netfilter Configuration →  IPv6 NAT

→ Networking support → Networking options → Network packet filtering framework (Netfilter) →    Ethernet Bridge nf_tables support

→ Networking support → Networking options → Network packet filtering framework (Netfilter) →    Ethernet Bridge tables (ebtables) support

→ Networking support → [ ]   Wireless  ----

→ Networking support → < >   WiMAX Wireless Broadband support  ----

→ Networking support → < >   RF switch subsystem support  --->

→ Networking support → < >   Bluetooth subsystem support  ---

→ Networking support → < >   CAN bus subsystem support  ----

→ Networking support → < >   IrDA (infrared) subsystem support  ----

→ Networking support → < >   CAIF support  ----

→ Networking support → < >   NFC subsystem support  ----

→ Device Drivers → Network device support → Ethernet driver support → < > ALL

→ Device Drivers → Network device support → Ethernet driver support →  Intel ...

→ Device Drivers → Network device support → Ethernet driver support →  Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support

→ Device Drivers → Network device support → < >   FDDI driver support

→ Device Drivers → Network device support → < >   PLIP (parallel port) support

→ Device Drivers → Network device support → [ ]   Wireless LAN  ----

→ Device Drivers → Network device support → < >   IEEE 802.15.4 drivers  ----

→ Device Drivers → Network device support → [ ]   ISDN support  ----

 → Device Drivers → < > Multimedia support  ----

→ Device Drivers → Sound card support →    Advanced Linux Sound Architecture  --->

→ Device Drivers → USB support →      xHCI HCD (USB 3.0) support

→ Device Drivers → USB support →      EHCI HCD (USB 2.0) support

→ Device Drivers →   VFIO Non-Privileged userspace driver framework

→ Device Drivers → [*] IOMMU Hardware Support  --->

另外附有同為 P503 電腦 Po-Ming 老師所設定的 config 檔:
點此下載

c. 開始跑編譯 (於 /usr/src/linux 目錄下)
time make-kpkg --initra --revision=1.0.1.versionName kernel_image -j 8

d. 編完後,安裝核心 (於 /usr/src 目錄下)
cd /usr/src
dpkg -i linux-image-3.14.34*.deb

e. 重新開機,並選用新核心開啟
reboot

f. 編完以後可以查看:

核心容量大小 vmlinuz, initrd :
du -sh /lib/modules/*

模組容量大小modules :
du -sh /boot/*

二、其他相關補充

於同一個核心下,想要修改選單參數,可以只編模組,編完再丟到 /lib/modules/3.14.34/ 目錄下,編譯指令如下:
time make modules -j 8











Reference:
http://pominglee.blogspot.tw/p/linux_9.html

沒有留言:

張貼留言