Both methods [Linux] kernel is loaded .ko: insmod and modprobe

Suppose you want to load the driver module called hello.ko

Load the module
method: 
go to the directory where the file hello.ko drive module, and then directly 
insmod hello.ko 

Method two: 
the file to copy hello.ko / lib / module / # uname -r # / directory, here, # uname -r # mean, in a terminal 
display after uname -r name and version of the kernel.

Then 
depmod (uname will be in / lib / modules / # modules.dep generation and modules.dep.bb files -r # / directory, show dependencies modules) 
last 
modprobe the Hello (note here without having to enter .ko suffix) 

The difference between the two methods:

And the insmod modprobe similar, are used to dynamically load the module, except that the dependencies can be resolved when modprobe the load module, which is obtained by / lib / modules / # uname -r / modules.dep (.bb) file to find dependencies; and insmod does not resolve dependencies.

That is, if you are sure you want to load the drive module does not rely on another drive module, it can be either insmod modprobe, insmod of course, it can be executed in any directory, more convenient. And if you want to load the driver module also rely on other ko driver module, then it can only be copied to the module above a specific directory, depmod and then modprobe.

Guess you like

Origin blog.csdn.net/zztingfeng/article/details/92012965