當前位置:首頁 » 編程軟體 » linux編譯好的內核

linux編譯好的內核

發布時間: 2022-08-04 06:14:15

⑴ 如何編譯linux內核

編譯linux內核步驟:
1、安裝內核
如果內核已經安裝(/usr/src/目錄有linux子目錄),跳過。如果沒有安裝,在光碟機中放入linux安裝光碟,找到kernel-source-2.xx.xx.rpm文件(xx代表數字,表示內核的版本號),比如RedHat linux的RPMS目錄是/RedHat/RPMS/目錄,然後使用命令rpm -ivh kernel-source-2.xx.xx.rpm安裝內核。如果沒有安裝盤,可以去各linux廠家站點或者www.kernel.org下載。
2、清除從前編譯內核時殘留的.o 文件和不必要的關聯
cd /usr/src/linux
make mrproper
3、配置內核,修改相關參數,請參考其他資料
在圖形界面下,make xconfig;字元界面下,make menuconfig。在內核配置菜單中正確設置個內核選項,保存退出
4、正確設置關聯文件
make dep
5、編譯內核
對於大內核(比如需要SCSI支持),make bzImage
對於小內核,make zImage
6、編譯模塊
make moles
7、安裝模塊
make moles_install
8、使用新內核
把/usr/src/linux/arch/i386/boot/目錄內新生成的內核文件bzImage/zImage拷貝到/boot目錄,然後修改/etc/lilo.conf文件,加一個啟動選項,使用新內核bzImage/zImage啟動。格式如下:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux-new ### 告訴lilo預設使用新內核啟動linux ###
append="mem=256M"
image=/boot/vmlinuz-2.2.14-5.0
label=linux
read-only
root=/dev/hda5
image=/boot/bzImage(zImage)
label=linux-new
read-only
root=/dev/hda5
保留舊有的啟動選項可以保證新內核不能引導的情況,還可以進入linux進行其他操作。保存退出後,不要忘記了最重要的一步,運行/sbin/lilo,使修改生效。
9、重新生成ram磁碟
如果您的系統中的/etc/lilo.conf沒有使用了ram磁碟選項initrd,略過。如果您的系統中的/etc/lilo.conf使用了ram磁碟選項initrd,使用mkinitrd initrd-內核版本號,內核版本號命令重新生成ram磁碟文件,例如我的Redhat 6.2:
mkinitrd initrd-2.2.14-5.0 2.2.14-5.0
之後把/etc/lilo.conf中的initrd指向新生成的initrd-2.2.14-5.0文件:
initrd=/boot/initrd-2.2.14-5.0
ram磁碟能使系統性能盡可能的優化,具體參考/usr/src/linux/Documents/initrd.txt文件
10、重新啟動,OK!

⑵ 在linux上編譯內核

看上去像是 gcc 有問題, 按理它應該調用的是cc去編譯,你的不知道為什麼在試圖使用cc1……

你先用 gcc去嘗試編譯一個簡單的.c文件,比如自己寫一個 hello world程序,看看 gcc 能不能編譯,如果可以,那麼可能是內核makefile的問題,試一下
make mrproper
然後再去 make menuconfig

如果你的hello world程序都沒法編譯,說明確實是gcc的問題,建議你重新安裝gcc,不知道你的linux是什麼版本,建議去參考你linux發行版的手冊去看如何安裝編譯環境,防止錯漏安裝包。 不過還是給你一個非常規的解決方法,進入你gcc安裝目錄,一般gcc是在 /usr/bin/ 目錄下 (可以用 which gcc查看gcc所在目錄),然後ls cc 看看,是否存在cc這個文件,如果有,那麼 ln -s cc cc1 (要用 root 身份來執行這條命令), 然後再去試試 gcc,應該不報錯了吧。

上面給你的這個非常規解決方法可能只能解決你提出的這個問題,但是如果你gcc安裝的有問題,缺了什麼東西了話,這個方法解決了這個問題,你肯定還會遇到其他問題的,建議還是按照正規方式安裝gcc及其相關依賴包。

⑶ linux編譯好了內核,也編譯好了內核模塊,最後內核放在fllash中,內核模塊放哪裡

問題補充:如題了,linux模塊編程為什麼要編譯內核源碼樹。以及為什麼內核版本當然需要。。。 第一點,就是源碼樹中有相應的頭文件和函數的實現,沒有

⑷ linux內核編譯的幾點疑惑

1.不一定是升級。一般編譯內核有升級某些特性修正一些bug,但是也有精簡來適應自己的機子硬體。
2.編譯成功後的內核與原來內核沒有影響(除非將原來的覆蓋),原來的內核最好保留,避免新內核運行不成功。
3.編譯的新內核主要看你自己在config文件上的配置。

⑸ 關於Linux內核編譯,如果我已經編譯好內核,那麼下一步怎麼辦,如何用它替換我現在已經裝好的linux的內核

RH9 不要折騰了,你升級了內核也沒有意義。

⑹ linux如何編譯安裝新內核支持NTFS文件系統(

第一步: 對硬體進行設置,使其滿足要求並下載內核:

1. 新添加一塊20G的硬碟及修改內存:

⑺ 編譯好的Linux0.11內核 如何運行

你還需要准備一個initrd,然後使用qemu的命令啟動,使用你的image和initrd,配置好參數就可以了。system.map啟動不需要

⑻ Linux 2.6.34內核編譯

Linux-2.6.34內核編譯指南
2010-06-11 22:45 作者:瑋琦 頁面排版:瑋琦

對linux內核的編譯來說是每個編譯者都必須掌握的一個階段,但是編譯內核是有相對一些難度的,也許你可能不知如何著手,請不必為此煩惱或者放棄,經過一些歸納和總結我編寫了比較詳細的步驟,從而可以為廣大的愛好者以及新手能帶來更好的幫助和深入的了解

一、下載內核
到www.kernel.org 下載新內核到 /usr/src
下載建議最好下載比當前已安裝版本高的內核我下載的是 linux-2.6.34.tar.bz2( 原來的內核是 2.6.18-128.e15-i686)
★ 我察看當前內核的版本

[root@localhost~]#uname -a
Linux localhost.localdomain 2.6.18-128.e15-i686 #1 SMP Tue Jun 8 10:30:55 CST 2010 i686 i686 i386 GNU/Linux
然後將其解壓到/usr/src目錄下,使用下面的命令解壓得到linux-2.6.34:
[root@localhost~]#tar -jxvf linux-2.6.34.tar.bz2
[root@localhost~]#bzip2 -d linux-2.6.34.tar.bz2

如果所下載的是.tar.gz(.tgz)文件,請使用下面的命令:

[root@localhost~]#tar -zxvf linux-2.6.34.tar.gz

為了不把原來的目錄覆蓋掉所以呢在當前路徑下做一個鏈接為linux:

[root@localhost~]#ln -s /usr/src/linux-2.6.34 /usr/src/linux

二、配置內核
[root@localhost~]#make clean 清除原有不需要的模塊和文件(垃息)
[root@localhost~]#make mrproper 清理源代碼數
[root@localhost~]#make menuconfig 基於ncurse的圖形配置界面,可以在文本下以菜單方式,進行配置。
Load an Alternate Configuration File,導入.config文件
註:內核配置有兩種方法,一種是直接置入內核* ;另一種是編成模塊M ;兩種方法各有優點;直接編入內核的,比如設備的啟動,不再需要載入模塊的這一過程了;而編譯成模塊,則需要載入設備的內核支持的模塊;但直接把所有的東西都編入內核也不是可行的,內核體積會變大,系統負載也會過重。我們編內核時最好把極為重要的編入內核;其它的如果您不明白的,最好用默認.
移動鍵盤上下左右鍵,按Enter 進入一個目錄。把指針移動到Exit就退出當前目錄到上級目錄;
下面圖形界面藍色區域為選擇區:
General setup -→
[*] Enable loadable mole support --->
-*- Enable the block layer -→
Processor type and features --->
Power management and ACPI options --->
Bus options (PCI etc.) --->
Executable file formats / Emulations --->
-*- Networking support --->
Device Drivers -→
Firmware Drivers --->
File systems --->
Kernel hacking -→
Security options --->
-*- Cryptographic API -→
[*] Virtualization -→
Library routines --->
---
Load an Alternate Configuration File
Save an Alternate Configuration File

<Select> < Exit > < Help >

修改完畢選擇Save an Alternate Configuration File,然後退出配置
[root@localhost~]#cp ../kernels/2.6.18-128.e15-i686/.config /usr/src
★ 編輯配置文件.config

[root@localhost~]#vim .config

找到105行的"#CONFIG_SYSFS_DEPRECATED is not set"改為"CONFIG_SYSFS_DEPRECATED=y" 保存
假如不修改該行,在升級重新啟動後會報如下的錯,導致啟動失敗

Volume group "VolGroup00" not found

Unalbe to access resume device (/dev/VolGroup00/LogVol00)

mount: could not find filesystem '/dev/root'

setuproot:moving /dev failed: No such file or directory

setuproot:error mounting /proc: No such file or directory

setuproot:error mounting /sys: No such file or directory

switchroot: mount failed: No such file or directory

Kernel panic - not syncing:Attempted to kill init!

★ 編譯開始,大概需要半個小時到一個小時的時間自己可以倒杯涼茶耐心候。

[root@localhost~]#make

★ 編譯外掛模塊和需要載入的模塊安裝

[root@localhost~]#make moles && make moles_install

這時候會出現3個警告[2]

WARNING: No mole dm-mem-cache found for kernel 2.6.34, continuing anyway

WARNING: No mole dm-message found for kernel 2.6.34, continuing anyway
WARNING: No mole dm-raid45 found for kernel 2.6.34, continuing anyway
經過測試,這3個警告不會影響內核的升級

★ 編譯系統內核且生成新的內核文件

[root@localhost~]#make bzImage

[root@localhost~]#cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.34

[root@localhost~]#mkinitrd /boot/initrd-2.6.34.img 2.6.34

[root@localhost~]# cp /boot/initrd-2.6.34.img /tmp

[root@localhost~]#cd /tmp/

[root@localhost~]#ls

[root@localhost~]#initrd-2.6.34.img

[root@localhost~]#mkdir newinitrd

[root@localhost~]# cd newinitrd/

[root@localhost~]# zcat ../initrd-2.6.34.img |cpio -i

[root@localhost~]# ls

bin dev etc init lib proc sbin sys sysroot

[root@localhost~]#vim init

★ 刪掉重復的兩行,有些情況下是沒有就不要執行

echo "Loading dm-region-hash.ko mole"

insmod /lib/dm-region-hash.ko

echo "Loading dm-region-hash.ko mole"

insmod /lib/dm-region-hash.ko

★ 重新打包initrd

[root@localhost~]# find .|cpio -c -o > ../initrd

[root@localhost~]# cd ..

[root@localhost~]# gzip -9 < initrd > initrd-2.6.34.img

★ 將initrd重新復制到/boot目錄下

[root@localhost~]#cp initrd-2.6.34.img /boot

★ 給 /boot/grub/grub.conf中添加一個新的啟動項,

[root@localhost~]#vim /boot/grup/grup.conf

如我的 grub.conf 增加了
如下一段文字
title Red Hat(2.6.34)
root (hd0,5)
kernel /boot/vmlinuz-2.6.34 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.34.img

三、重新起動
[root@localhost~]# reboot
★ 啟動成功後查看當前內核版本號

[root@localhost~]#uname -r
2.6.34
四、待解決的問題

★ Iptables啟動失敗

操作系統啟動過程中出現下面的錯誤信息:

Applying ip6tables firewall rules: ip6tables-restore v1.3.5: ip6tables-restore:unable to initalizetable 'filter'

Error accurred at line: 3

Try "ip6tables-restore -h' or 'ip6tables-restore --help' for more information.

Applying iptables firewall rules: iptables-restore v1.3.5: iptables-restore:unable to initalizetable 'filter'

Error accurred at line: 3

Try "iptables-restore -h' or 'iptables-restore --help' for more information.

啟動後嘗試手動啟動防火牆:

[root@localhost~]#service iptables status

防火牆已停

[root@localhost~]#service iptables start

正在卸載 Iiptables 模塊:[確定]

應用 iptables 防火牆規則:iptables-restore v1.3.5: iptables-restore: unable to initializetable 'filter'

Error occurred at line: 3

Try `iptables-restore -h' or 'iptables-restore --help' for more information.

[失敗]

★ Hidd(Bluetooth HID daemon)啟動失敗

Starting hidd: Can't open HIDP control socket: Address family not supported by protocol [FAILED]

[root@localhost~]# service hidd status

hidd 已死,但是 subsys 被鎖

[root@localhost~]# service hidd start

正在啟動 hidd:Can't open HIDP control socket: Address family not supported by protocol

⑼ linux內核編譯問題 vmware內編譯好內核如何在其他主機上安裝

你這水平要加油了。
1. 沒有網卡的話,可以增加個usb口的網卡呢。一個才十幾塊錢。usb口絕對有。配置好ip地址,直接傳,如scp.
2. 拷貝內核,moles, 到U盤。
然後目標機器掛載U盤。
dmesg 識別到u盤。
然後掛載u盤:mount掛載下。
然後手動安裝內核,生成initxxxx文件,修改bootloader內核優先順序。
最後 sync 然後eject彈出u盤即可。
3. 硬碟介面等傳文件。
4. 人人順風順水的回答沒有問題,簡明,是你水平太差看不懂而已。
5. 內核目錄里有個Documentation, 你多閱讀下

⑽ 裸機運行編譯好的linux內核!

裸機無法運行單純的一個linux內核。
但可以最小化的安裝linux系統,
這個你可以去了解gentoo archlinux以及終極的LFS

熱點內容
樹莓派源碼 發布:2025-02-09 05:07:00 瀏覽:650
安卓手機為什麼搜不到懂球帝 發布:2025-02-09 05:04:42 瀏覽:817
生命密碼解讀走什麼 發布:2025-02-09 04:55:51 瀏覽:279
python常用正則表達式 發布:2025-02-09 04:42:53 瀏覽:178
機器人編程培訓哪家好 發布:2025-02-09 04:37:44 瀏覽:308
上海怎麼學習java 發布:2025-02-09 04:26:39 瀏覽:23
erp系統搭建備用伺服器 發布:2025-02-09 04:07:38 瀏覽:946
戴爾伺服器在bios怎麼配置管理ip 發布:2025-02-09 04:01:53 瀏覽:551
小魚易連雲存儲 發布:2025-02-09 03:59:47 瀏覽:92
正在限制訪問 發布:2025-02-09 03:47:17 瀏覽:904