LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 11-26-2008, 12:50 AM   #1
duyuyang
Member
 
Registered: Mar 2008
Posts: 56

Rep: Reputation: 16
How to force remove a kernel module


I am developing a kernel module. Something wrong happens, so I want to remove this module. But the kernel says it is in use, even I add the force option to rmmod utility, it is still holding there.

rmmod **** -f
ERROR: Removing '****': Device or resource busy

Anyone knows what I should do, other than reboot.

Thanks,
Shawn

Last edited by duyuyang; 11-26-2008 at 12:57 AM.
 
Old 11-26-2008, 01:25 AM   #2
datopdog
Member
 
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806

Rep: Reputation: 41
Try
Code:
modprobe -rf
 
Old 11-26-2008, 01:39 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You may need to remove modules that depend on the module. You may also need to stop a service that uses it. One example shutting down a NIC device before unloading the kernel module for that device. Not doing so could lead to a lockup.
 
Old 11-26-2008, 08:59 PM   #4
duyuyang
Member
 
Registered: Mar 2008
Posts: 56

Original Poster
Rep: Reputation: 16
Thank you both.

Quote:
Originally Posted by jschiwal View Post
You may need to remove modules that depend on the module. You may also need to stop a service that uses it. One example shutting down a NIC device before unloading the kernel module for that device. Not doing so could lead to a lockup.
The module communicates with a user space partner using Netlink.
It might not have any other modules dependent on it.
Anyway, I want to know if I can get the information about what modules or kernel threads or anything depend on a certain given module.

BTW: Distro is short for distribution. Why the O? It is interesting. Maybe distribution, have you got any better explanation?
 
Old 11-26-2008, 09:04 PM   #5
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
modinfo will show what other module is a dependency.

rmmod -f will only work if CONFIG_MODULE_FORCE_UNLOAD is enabled in the kernel ... not sure if modprobe -r has the same restriction.

Last edited by dxqcanada; 11-26-2008 at 09:05 PM.
 
1 members found this post helpful.
Old 11-26-2008, 09:13 PM   #6
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Run "lsmod". On the right hand side of the line are the modules that depend on the module on the left.
Code:
lsmod | grep i2c
i2c_nforce2            24704  0
i2c_core               45344  2 nvidia,i2c_nforce2
The nvidia and i2c_nforce2 depend on the i2c_core module, so I couldn't simply remove the i2c_core module.
Code:
/sbin/modinfo nvidia | grep -v -e alias: -e parm:
filename:       /lib/modules/2.6.25.18-0.2-default/weak-updates/nvidia.ko
license:        NVIDIA
depends:        i2c-core
supported:      external
vermagic:       2.6.25.11-0.1-default SMP mod_unload
The modinfo can supply more information about modules. Here you see that nvidia needs the i2c-core module.
 
Old 11-27-2008, 01:42 AM   #7
duyuyang
Member
 
Registered: Mar 2008
Posts: 56

Original Poster
Rep: Reputation: 16
Quote:
Try modprobe -rf
modprobe -rf is more powerful than rmmod, sometimes it can remove an in use module. Don't know why, in some other cases, I just learned that.
So thank datopdog.

Module may not be removed by rmmod even if no other modules depend on it, according to the dependency information obtained from lsmod.

Thank you all. I learned a lot about modules and their dependency from you.

All the best,
Shawn

Last edited by duyuyang; 11-27-2008 at 01:43 AM.
 
1 members found this post helpful.
  


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
How Can I Force Removal of a Kernel Module (ERROR: Module usb_storage is in use) klearview Linux - Software 2 10-10-2008 09:20 PM
how to remove a module from kernel htamayo Debian 1 06-18-2008 11:31 AM
JMicron controller issues + how do I permanently remove a module from the kernel? xtknight Linux - Hardware 10 03-28-2007 08:25 AM
unable to remove kernel module........ dogslayer Linux - Software 6 03-27-2006 12:26 AM
How to remove module from kernel without recompile? Stoic Linux - Software 10 09-23-2003 06:17 PM


All times are GMT -5. The time now is 12:08 AM.

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