This brief post is designed to explain what a Loadable Kernel Module is.
In the beginning, there was the Linux Kernel. Linus Torvalds designed it so that the code you needed to operate the base devices on your system would be compiled into the kernel, after all, as Open Source Software, everyone had the capability (if not the skill) to recompile the source as needed.
Around 1995, Loadable Kernel Modules (LKM's) were introduced into Linux. While not entirely synonymous, these are about the closest things in Linux to what windows users would know as Device Drivers (something like Windows .vxd's)
An LKM is a separately compiled piece of source code, which is linked against the kernel you are running so that it is "pluggable" and can be enabled or disabled even while the base Linux kernel is running. To see what Kernel Modules you have installed you can type lsmod at a shell prompt. Here's what I see on my Dell Inspiron 6000 notebook (this list is a little long, but just skim it quickly so you get the idea of what is there):
Module Size Used by
binfmt_misc 13448 1
rfcomm 42260 0
l2cap 27136 5 rfcomm
bluetooth 53348 4 rfcomm,l2cap
xt_limit 3840 2
xt_pkttype 2944 1
xt_tcpudp 4480 28
ipt_LOG 8320 11
xt_state 3328 6
iptable_mangle 3968 0
iptable_nat 8964 0
iptable_filter 4224 1
ip_conntrack_irc 7920 0
ip_nat_ftp 4736 0
ip_nat 19884 2 iptable_nat,ip_nat_ftp
ip_conntrack_ftp 8816 1 ip_nat_ftp
ip_conntrack 53088 6 xt_state,iptable_nat,ip_conntrack_irc,ip_nat_ftp
,ip_nat,ip_conntrack_ftp
nfnetlink 8088 2 ip_nat,ip_conntrack
ip_tables 15204 3 iptable_mangle,iptable_nat,iptable_filter
x_tables 16132 7 xt_limit,xt_pkttype,xt_tcpudp,ipt_LOG,xt_state,i
ptable_nat,ip_tables
speedstep_lib 5764 0
cpufreq_userspace 5408 0
cpufreq_stats 7744 0
freq_table 6048 1 cpufreq_stats
cpufreq_powersave 2944 0
cpufreq_ondemand 8876 0
cpufreq_conservative 8712 0
video 17412 0
tc1100_wmi 8324 0
sbs 16676 0
sony_acpi 6412 0
pcc_acpi 14080 0
i2c_ec 6272 1 sbs
i2c_core 23424 1 i2c_ec
hotkey 11556 0
dev_acpi 12164 0
button 7952 0
battery 11652 0
container 5632 0
ac 6788 0
asus_acpi 17688 0
ipv6 271136 18
sg 37020 0
sd_mod 22528 0
lp 12964 0
tsdev 9152 0
psmouse 41352 0
usb_storage 74816 0
libusual 16912 1 usb_storage
serio_raw 8452 0
snd_hda_intel 20244 2
snd_hda_codec 164480 1 snd_hda_intel
8139cp 24960 0
8139too 29056 0
ati_agp 10636 0
agpgart 35016 1 ati_agp
shpchp 42144 0
pci_hotplug 32828 1 shpchp
parport_pc 37796 1
parport 39368 2 lp,parport_pc
usbhid 45280 0
pcspkr 4352 0
mii 6912 2 8139cp,8139too
snd_pcm_oss 47232 0
snd_mixer_oss 19328 1 snd_pcm_oss
snd_pcm 84356 3 snd_hda_intel,snd_hda_codec,snd_pcm_oss
snd_timer 25348 1 snd_pcm
snd 58116 10 snd_hda_intel,snd_hda_codec,snd_pcm_oss,snd_mix
er_oss,snd_pcm,snd_timer
soundcore 11232 1 snd
snd_page_alloc 11528 2 snd_hda_intel,snd_pcm
evdev 11392 1
ext3 142344 1
jbd 62100 1 ext3
ehci_hcd 35208 0
ohci_hcd 22788 0
usbcore 134656 6 usb_storage,libusual,usbhid,ehci_hcd,ohci_hcd
ide_generic 2432 0
ide_cd 33696 0
cdrom 38944 1 ide_cd
ide_disk 18560 3
atiixp 7824 1
generic 6276 0
sata_sil 11016 0
libata 74764 1 sata_sil
scsi_mod 144392 4 sg,sd_mod,usb_storage,libata
thermal 15624 0
processor 31560 1 thermal
fan 6020 0
ehci_hcd 35208 0
ohci_hcd 22788 0
usbcore 134656 6 usb_storage,libusual,usbhid,ehci_hcd,ohci_hcd
ide_generic 2432 0
ide_cd 33696 0
cdrom 38944 1 ide_cd
ide_disk 18560 3
atiixp 7824 1
generic 6276 0
sata_sil 11016 0
libata 74764 1 sata_sil
scsi_mod 144392 4 sg,sd_mod,usb_storage,libata
thermal 15624 0
processor 31560 1 thermal
fan 6020 0
fbcon 41376 0
tileblit 3840 1 fbcon
font 9344 1 fbcon
bitblit 7296 1 fbcon
softcursor 3328 1 bitblit
vesafb 9244 0
capability 5896 0
commoncap 8704 1 capability
(END)
To activate a compiled module that isn't showing on this list, the tool modprobe is used. For example, while I was getting my proprietary wireless card working, I had to run:
modprobe ndiswrapper
To remove a module, you can use:
modprobe -r ndiswrapper
Or, alternatively: rmmod ndiswrapper
That being said, you probably shouldn't be adding or removing modules if everything is working fine, unless you have a very good reason to do so.
The very brave and memory-thrifty user might scour the list analyzing the sizes and if a module is unused and unneeded, remove it. For example, since I don't plan on using any bluetooth devices whatsoever, I might remove bluetooth, l2cap, and rfcomm, which are all related to bluetooth. (I looked them up on Google to make sure.) But, since I'm not really that adventurous, and don't know if there are any side effects, I'm not going to do that. :-)
Some modules of note in my list are snd_hda_intel & snd_hda_codec, which make my particular variety of sound card work, and... hmm, It's gone now. I could have sworn ndiswrapper was in my list, as I jumped through all sorts of hoops to get my wireless networking working with it, but I don't see it now. The network card is working, though, so I'm not going to touch it. None of the other modules I have installed are of particular interest to me: They have been doing their job, and I haven't had to even know they are there.
Well, I hope this was a little helpful in understanding what LKM's are and how to manage them.
No comments:
Post a Comment