構建linux核心樹

來源:互聯網
上載者:User
構建linux核心樹

轉載自:http://hi.baidu.com/wdr_cloud/item/a101178d02f5d6934514cf57

以下內容僅供個人學習之用,切勿挪用他途。

先查看自己OS使用的核心版本

shana@shana:~$ uname -r
2.6.22-14-generic /* 這是我顯示的結果 */

如果安裝系統時,自動安裝了源碼。在 /usr/src 目錄下有對應的使用的版本目錄。例如下(我是自己下的)

shana@shana:/usr/src$ ls
linux-headers-2.6.22-14
linux-headers-2.6.22-14-generic
linux-source-2.6.22 /*這個就是解壓後的源碼目錄 */
linux-source-2.6.22.tar.bz2 /* 這是我下的源碼 包 */
shana@shana:/usr/src$

如果沒有源碼。(一般ubuntu 都沒有吧)
查看一下可一下載的源碼包(切記不要使用超級使用者使用此命令否則……會提示沒有此命令)

shana@shana:/usr/src$ apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
xen-source-2.6.16 - Linux kernel source for version 2.6.17 with Ubuntu patches
linux-source-2.6.22 - Linux kernel source for version 2.6.22 with Ubuntu patches
shana@shana:/usr/src$

我選擇了 linux-source-2.6.22 - Linux kernel source for version 2.6.22 with Ubuntu patches 這個~
然後 install 之

shana@shana:/usr/src$ sudo apt-get install linux-source-2.6.22

下載完成後,在/usr/src下,檔案名稱為:linux-source-2.6.22.tar.bz2,是一個壓縮包,解壓縮既可以得到整個核心的原始碼:

注意 已經切換到超級使用者模式

root@shana:/usr/src#tar jxvf linux-source-2.6.20.tar.bz2

解壓後產生一個新的目錄/usr/src/linux-source-2.6.22,所有的原始碼都在該目錄下。

進入該目錄

開始配置核心 選擇最快的原版的配置(預設)方式 (我是如此)

root@shana:/usr/src/linux-source-2.6.22# make oldconfig

當然你也可以使用 自己喜歡的配置方式 如 menuconfig , xconfig(必須有GTK環境吧)。反正不用剪裁什麼,所以不管那種方式能配置它就行了。

完成後,開始make 吧 這兒比較久 一般有1一個小時吧。(保證空間足夠 我編譯完成後 使用了1.8G) 我分區時分給/目錄30G的空間,我沒遇到這問題。倒是我朋友遇到了。

shana@shana:/usr/src/linux-source-2.6.22$ make

shana@shana:/usr/src/linux-source-2.6.22$ make bzImage

當然,第一個make也可以不執行,直接make bzImage。執行結束後,可以看到在目前的目錄下產生了一個新的檔案: vmlinux, 其屬性為-rwxr-xr-x。

然後 :

root@shana:/usr/src/linux-source-2.6.22#make modules /* 編譯 模組 */

root@shana:/usr/src/linux-source-2.6.22#make modules_install /* 安裝 模組 */

執行結束之後,會在/lib/modules下產生新的目錄/lib/modules/2.6.22-14-generic/
。 在隨後的編譯模組檔案時,要用到這個路徑下的build目錄。至此,核心編譯完成。可以重啟一下系統。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.