2013-07-10 106 views
5

我試圖編譯和模塊插入我的內核,但我不斷收到此錯誤:用insmod不能插入一個非常簡單的模塊

insmod: error inserting 'hello.ko': -1 Invalid module format 

我跟着本教程在這裏描述的步驟: http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html。而且一切似乎都有意義並且有效。我得到了我的示例模塊編譯,但有一個警告,可能是一個重要的原因導致這件事失敗。警告是這樣的:

WARNING: Symbol version dump /usr/src/linux-3.0.0/Module.symvers is missing; modules will have no dependencies and modversions.

我坦率地不知道爲什麼Module.symvers文件不存在。該/usr/src/linux-3.0.0目錄及其所有內容都是我創造了我使用此命令dowloaded來源後:

apt-get source linux-image-$(uname -r)

那是事實,教程的唯一步驟,我沒有遵循,因爲我無法找到我的內核的確切來源(3.0.0-32-通用),並認爲能力工具會對我進行分類。

我就是一個64位的機器上運行Ubuntu順便說一下,這裏是通過uname -a輸出:

Linux vega 3.0.0-32-generiC#51-Ubuntu SMP Thu Mar 21 15:50:59 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

任何建議,什麼嘗試下?任何推薦的閱讀?

PS1。 經過一些更多的研究,我確認我正在運行3.0.0-32-generic。更新GRUB返回:

Found linux image: /boot/vmlinuz-3.0.0-32-generic 

但發出須藤使oldconfig會,並檢查所產生的config文件,我得到這個有趣的行之後:

CONFIG_VERSION_SIGNATURE="Ubuntu 3.0.0-32.51-generic 3.0.69" 

這是否有資格作爲一個missmatch?

PS2。 dmesg的輸出這樣的:

[ 5.869900] ADDRCONF(NETDEV_UP): eth1: link is not ready 
[ 6.144304] EXT4-fs (dm-1): re-mounted. Opts: errors=remount-ro 
[ 6.368936] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null) 
[ 6.433919] vesafb: mode is 640x480x32, linelength=2560, pages=0 
[ 6.433921] vesafb: scrolling: redraw 
[ 6.433923] vesafb: Truecolor: size=8:8:8:8, shift=24:16:8:0 
[ 6.435424] vesafb: framebuffer at 0xb0000000, mapped to 0xffffc90012800000, using 1216k, total 1216k 
[ 6.435516] Console: switching to colour frame buffer device 80x30 
[ 6.443104] EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null) 
[ 6.450198] fb0: VESA VGA frame buffer device 
[ 8.884523] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx 
[ 8.885845] ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready 
[ 12.611236] init: ssh main process (762) terminated with status 255 
[ 12.624381] init: failsafe main process (752) killed by TERM signal 
[ 12.634739] type=1400 audit(1373412287.107:8): apparmor="STATUS" operation="profile_load" name="/usr/sbin/tcpdump" pid=852 comm="apparmor_parser" 
[ 12.634873] type=1400 audit(1373412287.107:9): apparmor="STATUS" operation="profile_replace" name="/sbin/dhclient" pid=851 comm="apparmor_parser" 
[ 12.635180] type=1400 audit(1373412287.107:10): apparmor="STATUS" operation="profile_replace" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=851 comm="apparmor_parser" 
[ 12.635403] type=1400 audit(1373412287.107:11): apparmor="STATUS" operation="profile_replace" name="/usr/lib/connman/scripts/dhclient-script" pid=851 comm="apparmor_parser" 
[ 19.390991] eth1: no IPv6 routers present 
[ 576.758697] hello: no symbol version for module_layout 
+0

你剛好運行後insmod的什麼dmesg的說,例如最後10行? – fghj

+0

我剛剛更新了問題以粘貼更多的dmesg輸出行,但我相信只有最後一個是相關的。 – Bilthon

+0

here http://stackoverflow.com/questions/1738539/how-do-i-fix-no-symbol-version-for-module-layout? – fghj

回答

7

當前的內核版本爲3.0.0-32-通用 去cd /lib/modules/3.0.0-32-gereric/目錄和檢查build目錄是否存在與否。如果存在,那麼您可以使用下面的命令

make -C /lib/modules/3.0.0-32-generic/build M=$(PWD) modules 

直接編譯你的模塊,如果你想與您下載然後 按照以下步驟內核編譯模塊:

cd /usr/src/linux-3.0.0/ 

make menuconfig 

make -j5 

make modules 

sudo make modules_install 

sudo make install 

sudo reboot 

然後引導你的系統Linux的內核3.0.0,並使用下面的命令編譯模塊:

make -C /lib/modules/3.0.0/build M=$(PWD) modules 
+0

謝謝,我會接受你的答案,因爲它是唯一提供的答案!我沒有經過你的步驟。相反,我編譯了一個新的內核,並在新的內核上運行insmod。它的工作,但我也注意到,即使我確實有源,他們沒有編譯,這可能是我的問題。 – Bilthon

+0

非常有幫助!我重啓後,insmod在5分鐘前工作的代碼給了我這個錯誤。我檢查了/ lib/modules,果然還有第二個版本號更高的dir。我切換了我的make文件以使用該版本,並且所有事情再次開始工作。 –