2014-11-24 39 views
2

我編寫了一個簡單的hello world內核模塊,編譯並安裝在/lib/modules/kernel_version/extra/的路徑中。找不到模塊:modprobe

隨着insmod它得到正確加載,但modprobe我得到

modprobe: FATAL: Module hello_world.ko not found. 

我已經安裝了所有的每一個必要的錯誤。

這裏是Makefile進行編譯和安裝:

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules_install 

請告訴我怎麼去完成。

在此先感謝。

回答

6

這是因爲modprobe插入通過讀取文件的模塊稱爲modules.dep/LIB /模塊/ $(殼UNAME -r)/。所以在編譯和安裝模塊之後,請確保重新創建這個依賴文件。

這裏是它是如何做

  1. After installation of your module, check whether it is copied to /lib/modules/
  2. if it is found, then go to ->/lib/modules/$(shell uname -r)/ and use depmod command to create the dependency list of your new module.


Once this is done, you will be able to locate your module name under the file /lib/modules/$(shell uname -r)/modules.dep.

這之後您可以使用modprobe您插入模塊。

編輯:

下面是我用來構建具有root權限和測試Makefile

target ?= hello_world 
obj-m = $(target).o 

all: 
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules_install 

clean: 
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean 
+0

同樣的錯誤: 一旦我運行Makefile模塊已經位於/ lib/modules/$(shell uname -r)/modules.dep。 – v123 2014-11-24 06:03:38

+0

INSTALL /home/vishal/test/linux_dd/hello_world.ko 無法讀取私鑰 DEPMOD 3.13.0-24-generic make [1]:離開目錄'/usr/src/linux-headers-3.13。上面的0-24-通用' – v123 2014-11-24 06:05:53

+0

是makefile的一些輸出片段。 – v123 2014-11-24 06:06:26

0

我曾經有同樣的問題。我的問題是,在發出命令時我沒有刪除擴展名。即

modprobe foo.ko 

給出了上述錯誤。但是這個:

modprobe foo 

作品!