LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-03-2009, 07:24 AM   #1
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Rep: Reputation: 18
Kernel Modules - Loading and Unloading Them


Hi,


The book "RH133" details Kernel Modules and that they are located under
Code:
 /lib/modules/
I would appreciate a good and typical example from you guys as to when we may need to load/reload/unload a Kernel Module and how we do that. Give some good scenario to elaborate it.


Thanks!

P.S.: Here's the listing of the loaded modules on this PC which I am using currently in lab:

Code:
[root@localhost modules]# ls
2.6.18-92.el5
[root@localhost modules]# lsmod

Module                  Size  Used by
i915                   23745  2 
drm                    65493  3 i915
autofs4                24517  2 
hidp                   23105  2 
rfcomm                 42457  0 
l2cap                  29505  10 hidp,rfcomm
bluetooth              53797  5 hidp,rfcomm,l2cap
sunrpc                144893  1 
ip_conntrack_netbios_ns     6977  0 
ipt_REJECT              9537  1 
xt_state                6209  2 
ip_conntrack           53025  2 ip_conntrack_netbios_ns,xt_state
nfnetlink              10713  1 ip_conntrack
iptable_filter          7105  1 
ip_tables              17029  1 iptable_filter
ip6t_REJECT             9409  1 
xt_tcpudp               7105  10 
ip6table_filter         6849  1 
ip6_tables             18053  1 ip6table_filter
x_tables               17349  6 ipt_REJECT,xt_state,ip_tables,ip6t_REJECT,xt_tcpudp,ip6_tables
cpufreq_ondemand       12493  2 
loop                   19017  0 
dm_mirror              29253  0 
dm_multipath           22089  0 
dm_mod                 61661  2 dm_mirror,dm_multipath
video                  21193  0 
sbs                    18533  0 
backlight              10049  1 video
i2c_ec                  9025  1 sbs
button                 10705  0 
battery                13637  0 
asus_acpi              19288  0 
ac                      9157  0 
ipv6                  258273  17 ip6t_REJECT
xfrm_nalgo             13765  1 ipv6
crypto_api             11969  1 xfrm_nalgo
lp                     15849  0 
snd_hda_intel          24793  2 
snd_hda_codec         210881  1 snd_hda_intel
snd_seq_dummy           7877  0 
snd_seq_oss            32577  0 
snd_seq_midi_event     11073  1 snd_seq_oss
snd_seq                49585  5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
snd_seq_device         11725  3 snd_seq_dummy,snd_seq_oss,snd_seq
snd_pcm_oss            42945  0 
snd_mixer_oss          19009  1 snd_pcm_oss
snd_pcm                72005  3 snd_hda_intel,snd_hda_codec,snd_pcm_oss
snd_timer              24517  2 snd_seq,snd_pcm
snd                    52421  13 snd_hda_intel,snd_hda_codec,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer
sg                     36189  0 
soundcore              11553  1 snd
floppy                 57125  0 
serio_raw              10693  0 
snd_page_alloc         14281  2 snd_hda_intel,snd_pcm
i2c_i801               11597  0 
pcspkr                  7105  0 
i2c_core               23745  2 i2c_ec,i2c_i801
parport_pc             29157  1 
ide_cd                 40033  0 
via_rhine              27597  0 
parport                37513  2 lp,parport_pc
cdrom                  36705  1 ide_cd
mii                     9409  1 via_rhine
r8169                  32969  0 
ata_piix               22341  4 
libata                143997  1 ata_piix
sd_mod                 24897  5 
scsi_mod              134605  3 sg,libata,sd_mod
ext3                  123593  3 
jbd                    56553  1 ext3
uhci_hcd               25421  0 
ohci_hcd               23261  0 
ehci_hcd               33357  0 
[root@localhost modules]#

Some clarifications, I need, here:

[1] Does "Size" denote the memory space being utilized by a particular module?

[2] What does "Used" denote here? Does it show how many times it is being used/loaded or reloaded?


Thanks again!
 
Old 09-03-2009, 11:44 PM   #2
foodown
Member
 
Registered: Jun 2009
Location: Texas
Distribution: Slackware
Posts: 609

Rep: Reputation: 218Reputation: 218Reputation: 218
Okay . . . I will attempt to answer your question. Feel free to follow-up with me if you do not think that I do an adequate job.

1) Yes, the 'size' column in an lsmod is the size of the module in memory. 'lsmod' itself is just a reformatting of the information which you can see by doing a 'cat /proc/modules'.

2) The 'used' column has a number, and then a list of other modules. The number is how many other modules are using that module in order to function. The list of other modules is a usually incomplete list of modules on which that modules depends.

So, for example, i915 has two other modules which depend on it, but does not depend on any other modules. Looking further down the list, you can see that the two modules which depend on i915 are drm and something else which is not apparent from 'lsmod'.

Now, and EXAMPLE of when you would want to insert a module.

Here is an excerpt from http://www.linuxquestions.org/questi...u-9.04-747997/ in which I showed MrCode how I built and inserted a module for his USB wireless LAN device. Of course, I do not own this device, so I then removed it with 'rmmod'.

Code:
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008# cp -raf firmware/RTL8192U /lib/firmware
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008# make
make[1]: Entering directory `/usr/src/linux-2.6.30.1'       
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_rx.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_softmac.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_tx.o     
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_wx.o     
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_wx.c: In function 'ieee80211_wx_set_gen_ie_rsl':
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_wx.c:990: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_module.o                                                                 
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_module.c: In function 'store_debug_level':                                         
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_module.c:308: warning: comparison of distinct pointer types lacks a cast           
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_softmac_wx.o                                                             
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_HTProc.o                                                                   
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_TSProc.o                                                                   
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.o                                                                   
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.c: In function 'ieee80211_rx_ADDBAReq':                                       
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.c:385: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'                                                                                                                                                             
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.c: In function 'ieee80211_rx_ADDBARsp':                                                   
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.c:484: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'                                                                                                                                                             
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.c: In function 'ieee80211_rx_DELBA':                                                      
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/rtl819x_BAProc.c:614: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'                                                                                                                                                             
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/dot11d.o                                                                                       
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt.o                                                                              
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_ccmp.o                                                                         
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_tkip.o                                                                         
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_wep.o                                                                          
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211-rsl.o                                                                                
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt-rsl.o                                                                          
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_wep-rsl.o                                                                      
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_tkip-rsl.o                                                                     
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_ccmp-rsl.o                                                                     
  Building modules, stage 2.                                                                                                                                  
  MODPOST 5 modules                                                                                                                                           
  CC      /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211-rsl.mod.o                                                                            
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211-rsl.ko                                                                               
  CC      /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt-rsl.mod.o                                                                      
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt-rsl.ko
  CC      /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_ccmp-rsl.mod.o
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_ccmp-rsl.ko
  CC      /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_tkip-rsl.mod.o
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_tkip-rsl.ko
  CC      /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_wep-rsl.mod.o
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211/ieee80211_crypt_wep-rsl.ko
make[1]: Leaving directory `/usr/src/linux-2.6.30.1'
make[1]: Entering directory `/usr/src/linux-2.6.30.1'
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.o
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c: In function 'rtl8192_rx_initiate':
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c:1179: warning: passing argument 4 of 'usb_fill_bulk_urb' makes pointer from integer without a cast
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c:1209: warning: passing argument 4 of 'usb_fill_bulk_urb' makes pointer from integer without a cast
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c: In function 'rtl8192_rx_isr':
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c:1590: warning: passing argument 4 of 'usb_fill_bulk_urb' makes pointer from integer without a cast
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c:1597: warning: assignment makes pointer from integer without a cast
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c: In function 'rtl8192_usb_initendpoints':
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c:2964: warning: cast from pointer to integer of different size
/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_core.c:2974: warning: cast to pointer from integer of different size
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8180_93cx6.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_wx.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8190_rtl8256.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r819xU_phy.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r819xU_firmware.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r819xU_cmdpkt.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192U_dm.o
  CC [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r819xU_firmware_img.o
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192_usb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192_usb.mod.o
  LD [M]  /usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u/r8192_usb.ko
make[1]: Leaving directory `/usr/src/linux-2.6.30.1'
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008#
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008#
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008#
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008# make install
make[1]: Entering directory `/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211'
make -C /lib/modules/2.6.30.1AMD_Bad_Boy/build M=/usr/src/rtl8192u_linux_2.6.0006.1031.2008 CC=gcc modules
make[2]: Entering directory `/usr/src/linux-2.6.30.1'
  Building modules, stage 2.
  MODPOST 0 modules
make[2]: Leaving directory `/usr/src/linux-2.6.30.1'
rm -fr /lib/modules/2.6.30.1AMD_Bad_Boy/kernel/drivers/net/wireless/RTL8192U
mkdir -p /lib/modules/2.6.30.1AMD_Bad_Boy/kernel/drivers/net/wireless/RTL8192U
depmod -a
make[1]: Leaving directory `/usr/src/rtl8192u_linux_2.6.0006.1031.2008/ieee80211'
make[1]: Entering directory `/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u'
make -C /lib/modules/2.6.30.1AMD_Bad_Boy/build M=/usr/src/rtl8192u_linux_2.6.0006.1031.2008 CC=gcc modules
make[2]: Entering directory `/usr/src/linux-2.6.30.1'
  Building modules, stage 2.
  MODPOST 0 modules
make[2]: Leaving directory `/usr/src/linux-2.6.30.1'
install -p -m 644 r8192_usb.ko  /lib/modules/2.6.30.1AMD_Bad_Boy/kernel/drivers/net/wireless/RTL8192U
make[1]: Leaving directory `/usr/src/rtl8192u_linux_2.6.0006.1031.2008/HAL/rtl8192u'
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008#
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008# insmod /lib/modules/2.6.30.1AMD_Bad_Boy/kernel/drivers/net/wireless/RTL8192U/r8192_usb.ko          
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008# lsmod                                                                                                 
Module                  Size  Used by                                                                                                                         
snd_seq_midi            7584  0                                                                                                                               
snd_emu10k1_synth       7200  0                                                                                                                               
snd_emux_synth         36544  1 snd_emu10k1_synth                                                                                                             
snd_seq_virmidi         6560  1 snd_emux_synth                                                                                                                
snd_seq_midi_emul       7008  1 snd_emux_synth                                                                                                                
cdc_acm                17920  0                                                                                                                               
vboxnetadp             99884  0                                                                                                                               
vboxnetflt            107276  0                                                                                                                               
vboxdrv              1711500  1 vboxnetflt
snd_seq_dummy           3236  0
snd_seq_oss            31744  0
snd_seq_midi_event      7520  3 snd_seq_midi,snd_seq_virmidi,snd_seq_oss
snd_seq                56896  9 snd_seq_midi,snd_emux_synth,snd_seq_virmidi,snd_seq_midi_emul,snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
snd_pcm_oss            43680  0
snd_mixer_oss          18400  1 snd_pcm_oss
ipv6                  285152  16
nfsd                  104744  9
lp                     12196  0
fuse                   60512  1
nvidia              10264104  36
b43                   132040  0
rfkill                 11508  1 b43
mac80211              154540  1 b43
ppdev                   8808  0
processor              38720  0
cfg80211               72280  2 b43,mac80211
led_class               4680  1 b43
input_polldev           4080  1 b43
thermal                16032  0
tulip                  55808  0
ssb                    46864  1 b43
thermal_sys            17248  2 processor,thermal
pcmcia                 36568  1 ssb
parport_pc             28616  1
parport                37680  3 lp,ppdev,parport_pc
pcmcia_core            37028  2 ssb,pcmcia
rtc_cmos               11928  0
rtc_core               19620  1 rtc_cmos
rtc_lib                 2912  1 rtc_core
snd_emu10k1           151136  3 snd_emu10k1_synth
snd_rawmidi            23360  3 snd_seq_midi,snd_seq_virmidi,snd_emu10k1
snd_ac97_codec        121784  1 snd_emu10k1
ac97_bus                1952  1 snd_ac97_codec
snd_pcm                81416  3 snd_pcm_oss,snd_emu10k1,snd_ac97_codec
snd_seq_device          7316  8 snd_seq_midi,snd_emu10k1_synth,snd_emux_synth,snd_seq_dummy,snd_seq_oss,snd_seq,snd_emu10k1,snd_rawmidi
snd_timer              22704  3 snd_seq,snd_emu10k1,snd_pcm
snd_page_alloc          9872  2 snd_emu10k1,snd_pcm
snd_util_mem            4128  2 snd_emux_synth,snd_emu10k1
snd_hwdep               8680  2 snd_emux_synth,snd_emu10k1
snd                    66824  17 snd_emux_synth,snd_seq_virmidi,snd_seq_oss,snd_seq,snd_pcm_oss,snd_mixer_oss,snd_emu10k1,snd_rawmidi,snd_ac97_codec,snd_pcm,snd_seq_device,snd_timer,snd_hwdep
i2c_nforce2             7712  0
emu10k1_gp              3488  0
psmouse                47452  0
gameport               11920  2 emu10k1_gp
soundcore               7328  1 snd
hwmon                   2760  1 thermal_sys
joydev                 12256  0
usblp                  14112  0
sg                     30656  0
button                  6560  0
evdev                  11648  8
serio_raw               6404  0
r8192_usb             239563  0
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008#
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008# rmmod r8192_usb
root@hydra5:/usr/src/rtl8192u_linux_2.6.0006.1031.2008#
 
  


Reply

Tags
kernel, modules


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
loading / unloading modules for Ubuntu atxhandy Ubuntu 1 12-15-2006 05:15 AM
module loading and unloading NeoUz Linux - Newbie 1 03-26-2005 04:52 AM
Automatically unloading modules? Levitate Linux - Newbie 5 10-21-2004 05:32 AM
Loading modules error after loading compiled kernel td0l2 Linux - Newbie 12 07-28-2004 12:10 PM
unloading modules Xris718 Linux - General 8 03-30-2004 04:30 PM


All times are GMT -5. The time now is 02:22 PM.

Main Menu
Advertisement
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