歡迎您光臨本站 註冊首頁

《Linux Kernel in a Nutshell (O』Reilly)》學習筆記

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

目的:熟悉和掌握內核編譯時方法和各個模塊的用途。
在沒有內核源代碼之前嘗試使用make menuconfig命令失敗!下載內核源代碼解壓進入其代碼根目錄使用上述命令執行成功!

下載內核源代碼:www.kernel.org

[root@localhost]~# pwd
/root
[root@localhost]~# tar xvf linux-2.6.23.tar.gz
[root@localhost]~# cd linux-2.6.23
[root@localhost]~/linux-2.6.23# ll
total 372
drwxr-xr-x 27 root root 4096 2007-10-10 04:31 arch
drwxr-xr-x 2 root root 4096 2007-10-10 04:31 block
-rw-r--r-- 1 root root 18693 2007-10-10 04:31 COPYING
-rw-r--r-- 1 root root 91484 2007-10-10 04:31 CREDITS
drwxr-xr-x 3 root root 4096 2007-10-10 04:31 crypto
drwxr-xr-x 68 root root 12288 2007-10-10 04:31 Documentation
drwxr-xr-x 72 root root 4096 2007-10-10 04:31 drivers
drwxr-xr-x 62 root root 4096 2007-10-10 04:31 fs
drwxr-xr-x 43 root root 4096 2007-10-10 04:31 include
drwxr-xr-x 2 root root 4096 2007-10-10 04:31 init
drwxr-xr-x 2 root root 4096 2007-10-10 04:31 ipc
-rw-r--r-- 1 root root 1581 2007-10-10 04:31 Kbuild
drwxr-xr-x 5 root root 4096 2007-10-10 04:31 kernel
drwxr-xr-x 6 root root 4096 2007-10-10 04:31 lib
-rw-r--r-- 1 root root 93316 2007-10-10 04:31 MAINTAINERS
-rw-r--r-- 1 root root 51306 2007-10-10 04:31 Makefile
drwxr-xr-x 2 root root 4096 2007-10-10 04:31 mm
drwxr-xr-x 42 root root 4096 2007-10-10 04:31 net
-rw-r--r-- 1 root root 16930 2007-10-10 04:31 README
-rw-r--r-- 1 root root 3119 2007-10-10 04:31 REPORTING-BUGS
drwxr-xr-x 9 root root 4096 2007-10-10 04:31 scripts
drwxr-xr-x 4 root root 4096 2007-10-10 04:31 security
drwxr-xr-x 19 root root 4096 2007-10-10 04:31 sound
drwxr-xr-x 2 root root 4096 2007-10-10 04:31 usr
[root@localhost]~/linux-2.6.23# make menuconfig // or "make xconfig" , or "make gconfig"
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/docproc
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/kxgettext.o
HOSTCC scripts/kconfig/lxdialog/checklist.o
HOSTCC scripts/kconfig/lxdialog/inputbox.o
HOSTCC scripts/kconfig/lxdialog/menubox.o
HOSTCC scripts/kconfig/lxdialog/textbox.o
HOSTCC scripts/kconfig/lxdialog/util.o
HOSTCC scripts/kconfig/lxdialog/yesno.o
HOSTCC scripts/kconfig/mconf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/mconf
scripts/kconfig/mconf arch/i386/Kconfig
#
# using defaults found in /boot/config-2.6.23.1-42.fc8
#
/boot/config-2.6.23.1-42.fc8:87:warning: trying to assign nonexistent symbol MODULE_VERIFY_ELF
...........................(其他省略)

此時啟動配置模塊界面。

chapter 8:
kernel configuration recipes
本章講述內核配置的一些方法:
Disks-->usb storage
$ /usr/sbin/lsusb -v | grep Storage
Disks--> IDE Disks (sata)
$ /usr/sbin/lspci | grep IDE
$ /usr/sbin/lspci | grep SATA
IEEE 1394(FireWire)
$ /usr/sbin/lspci | grep FireWire
Sound(ALSA)
$ /usr/sbin/lspci | grep -i audio
CPU
$ cat /proc/cpuinfo | grep "model name"
Suspend
$ /sbin/swapon -s | grep dev | cut -f 1 d ' '
Network Drivers
$ /usr/sbin/lspci | grep Ethernet
Wireless
$ /usr/sbin/lspci | grep -i wireless
Debug filesystem
如果打開了相關選項並重新啟動內核后,它就會創建/sys/kernel/debug目錄作為用戶掛載debugfs文件系統的位置,掛載方法:
$ mount -t debugfs none /sys/kernel/debug

Chapter 9:
kernel boot command-line parameter reference
可以通過三種方式來控制內核行為:編譯內核的時候,在啟動的時候(LILO,GRUB),還有就是在運行的的時候(通過向/proc和/sys目錄中的相關文件寫入參數)
本章講的是在啟動的時候控制內核行為:具體的可以查看內核源代碼Documentation/kernel-parameters.txt.

chapter 10:
kernel build command-line reference
本章講的是編譯內核的時候傳給make的參數,這些參數可以通過make help得到

chapter 11:
kernel configuration option reference
本章講的都是在make config中會碰到的一些選項。
示例如下:
make xconfing打開配置界面,EDIT--->FIND打開查找界面,輸入EXPERIMENTAL或者LOCALVERSION兩個選項來查找它們的所在。
同時,在代碼根的位置,使用grep -R EXPERIMENTAL * 可以看到這個選項(或者說是關鍵字)存在於很多源代碼的配置文件中。

[火星人 ] 《Linux Kernel in a Nutshell (O』Reilly)》學習筆記已經有852次圍觀

http://coctec.com/docs/linux/show-post-187680.html