LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 08-19-2009, 04:42 AM   #1
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Rep: Reputation: 15
insmod works but modprobe doesnt


Hi all,

I am someone trying to learn linux kernel programming. I read insmod and modprobe can be used for inserting a module in to the kernel. I created a simple kernel module and tried to insert using insmod it worked well. But when I used modprobe it showed error.

Quote:
[root@station121 kernel]# modprobe module1.ko
FATAL: Module module1.ko not found.
My module is a simple kernel module which just has a init_module function and a cleanup module function. I tried to insert from the path where my program and module resides.

I am using linux kernel 2.6.18 on a Centos 5 distribution. Please help me
 
Old 08-19-2009, 06:08 AM   #2
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.0 + 14.1
Posts: 4,828

Rep: Reputation: 431Reputation: 431Reputation: 431Reputation: 431Reputation: 431
Two things, the man page says modprobe looks in /lib/modules for loadable modules. Copy your module there and give it a go. Second, in suggests the name should have '-' or '_' in the name ( without the quotes ). You could rename the module as a second thing to try.

Hope this helps.
 
Old 08-19-2009, 10:44 AM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,237

Rep: Reputation: 121Reputation: 121
Like Cliff says: it has to be in the right place in /lib/modules/`uname -r` before you can use modprobe on a module.
 
Old 08-20-2009, 01:11 AM   #4
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks for the reply friends. As you have said I have copied my module into /lib/modules/2.6.18-53.el5 directory. The name of my module is module1.ko . And I tried modprobe again.But it is showing the same error message. What i did wrong ?....
 
Old 08-20-2009, 02:04 AM   #5
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
You should use the command

modprobe module1

not modprobe module1.ko Try that first, if it still doesn't work, try running depmod -a and check the permissions on the module file.
 
Old 08-20-2009, 10:42 AM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,237

Rep: Reputation: 121Reputation: 121
I think Uncle Theodore has it right with the suggestion to run "depmod -a". I believe that you have to be in /lib/modules/`uname -r`, and that your .ko file should be in the proper subdirectory under the kernel subdirectory.
 
Old 08-22-2009, 03:59 AM   #7
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks for the reply...As you have said I tried to use modprobe with only module name. Before that I copied my module in to the /lib/module/<uname -r> directory...But it still didnt work.


Quote:
cp module.ko /lib/modules/2.6.18-53.el5/
cd /lib/modules/2.6.18-53.el5
modprobe module

But I got the same error...Where can i learn about the subdirectories in the kernel path...As Quakeboy2 pointed out , I may be missing the trick by not putting my module in the proper subdirectory....
 
Old 08-23-2009, 01:41 AM   #8
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,237

Rep: Reputation: 121Reputation: 121
Did you run "depmod -a" after adding your driver?
 
Old 08-23-2009, 11:52 PM   #9
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks .. that does work...But I still didnt under stand the part ... This time I first inserted the module using insmod...Then I run depmod -a...Then I copied the module to /lib/modules/<uname -r> directory...I then removed the module using rmmod ... Then I tried modprobe with only module name and it does work..In total this is what i did...

Quote:
# insmod module1.ko
# depmod -a
# cp module1.ko /lib/modules/<uname -r>
# rmmod module1.ko
# cd /lib/modules<uname -r>
# modprobe module1
But why insert the module1.ko using insmod command first before using modprobe...That means whenever I want to insert a module using modprobe i must use insmod first ??
 
Old 08-23-2009, 11:57 PM   #10
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543
I think you just overlooked a step in your previous example. The steps would be:

1: put your module into /lib/modules/`uname -r`/kernel/drivers/HERE-SOMEWHERE
2: depmod
3: now either insmod or modprobe should work.
4: to remove the module, do "rmmod module1" or on a more modern OS, "modprobe -r module1"

FWIW, as I understand it, using modprobe does 'module dependency checking' and inserts related modules needed by the initial module, whereas 'insmod/rmmod' does not.

Also, you never need the .ko extension for modprobe.

Sasha

Last edited by GrapefruiTgirl; 08-24-2009 at 12:03 AM. Reason: EDIT: added /drivers to path --oops.
 
Old 08-24-2009, 04:26 PM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,237

Rep: Reputation: 121Reputation: 121
I believe your ordering is wrong and could cause you to be confused about what works and when.
Code:
# insmod module1.ko
# depmod -a
# cp module1.ko /lib/modules/<uname -r>
# rmmod module1.ko
# cd /lib/modules<uname -r>
# modprobe module1
Should probably be:
Code:
# cp module1.ko /lib/modules/`uname -r`
# depmod -a
# modprobe module1
NOTE: those are backquotes around uname -r. Type it exactly that way and it works without having to know the actual value of uname -r.

Notice that I copied the .ko first. Then ran depmod. Then, finally, did the modprobe. However, you should probably put it in the correct subdirectory under /lib/modules/`uname -r`
 
Old 08-24-2009, 11:45 PM   #12
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks all...Now I got it....Thank you very much...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
insmod vs modprobe python09 Linux - Newbie 5 11-28-2008 12:44 PM
modprobe and insmod not working navin_karnam Linux - General 8 07-31-2007 11:37 PM
modprobe or insmod? GT_Onizuka Linux - Newbie 7 04-10-2004 06:03 PM
modprobe or insmod agts Linux - Newbie 2 03-14-2004 01:18 PM
insmod/modprobe Problem Compuholic Linux - General 19 12-24-2002 10:39 AM


All times are GMT -5. The time now is 01:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration