Trying into Linux modules | Community World

The lsmod command can inform you which kernel modules are at present loaded in your system, together with some attention-grabbing particulars about their use.

What are Linux modules?

Kernel modules are chunks of code which might be loaded and unloaded into the kernel as wanted, thus extending the performance of the kernel with out requiring a reboot. In actual fact, until customers inquire about modules utilizing instructions like lsmod, they will not seemingly know that something has modified.

One necessary factor to know is that there are tons of modules that can be in use in your Linux system always and that loads of particulars can be found if you happen to’re tempted to dive into the small print.

One of many prime ways in which lsmod is used is to look at modules when a system is not working correctly. Nevertheless, more often than not, modules load as wanted and customers do not want to concentrate on how they’re working.

Itemizing modules

The simplest technique to checklist modules is with the lsmod command. Whereas this command gives loads of element, that is essentially the most user-friendly output.

$ lsmod
Module Measurement Utilized by
snd_hda_codec_realtek 114688 1
snd_hda_codec_generic 77824 1 snd_hda_codec_realtek
ledtrig_audio 16384 2 snd_hda_codec_generic,snd_hda_codec_realtek
snd_hda_codec_hdmi 53248 1
snd_hda_intel 40960 2
snd_hda_codec 131072 four snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel
,snd_hda_codec_realtek
snd_hda_core 86016 5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel
,snd_hda_codec,snd_hda_codec_realtek
snd_hwdep 20480 1 snd_hda_codec
snd_pcm 102400 four snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda
_core
snd_seq_midi 20480 0
snd_seq_midi_event 16384 1 snd_seq_midi
dcdbas 20480 0
snd_rawmidi 36864 1 snd_seq_midi
snd_seq 69632 2 snd_seq_midi,snd_seq_midi_event
coretemp 20480 0
snd_seq_device 16384 three snd_seq,snd_seq_midi,snd_rawmidi
snd_timer 36864 2 snd_seq,snd_pcm
kvm_intel 241664 0
kvm 626688 1 kvm_intel
radeon 1454080 10
irqbypass 16384 1 kvm
joydev 24576 0
input_leds 16384 0
ttm 102400 1 radeon
drm_kms_helper 180224 1 radeon
drm 475136 13 drm_kms_helper,radeon,ttm
snd 81920 15 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda
_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd
_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
i2c_algo_bit 16384 1 radeon
fb_sys_fops 16384 1 drm_kms_helper
syscopyarea 16384 1 drm_kms_helper
serio_raw 20480 0
sysfillrect 16384 1 drm_kms_helper
sysimgblt 16384 1 drm_kms_helper
soundcore 16384 1 snd
mac_hid 16384 0
sch_fq_codel 20480 2
parport_pc 40960 0
ppdev 24576 0
lp 20480 0
parport 53248 three parport_pc,lp,ppdev
ip_tables 28672 0
x_tables 40960 1 ip_tables
autofs4 45056 2
raid10 57344 0
raid456 155648 0
async_raid6_recov 24576 1 raid456
async_memcpy 20480 2 raid456,async_raid6_recov
async_pq 24576 2 raid456,async_raid6_recov
async_xor 20480 three async_pq,raid456,async_raid6_recov
async_tx 20480 5 async_pq,async_memcpy,async_xor,raid456,async_raid6_re
cov
xor 24576 1 async_xor
raid6_pq 114688 three async_pq,raid456,async_raid6_recov
libcrc32c 16384 1 raid456
raid1 45056 0
raid0 24576 0
multipath 20480 0
linear 20480 0
hid_generic 16384 0
psmouse 151552 0
i2c_i801 32768 0
pata_acpi 16384 0
lpc_ich 24576 0
usbhid 53248 0
hid 126976 2 usbhid,hid_generic
e1000e 245760 0
floppy 81920 0

Within the output above:

  • “Module” exhibits the identify of every module
  • “Measurement” exhibits the module measurement (not how a lot reminiscence it’s utilizing)
  • “Utilized by” exhibits every module’s utilization depend and the referring modules

Clearly, that is a lot of modules. The variety of modules loaded will rely in your system and distribution and what’s operating. We will depend them like this:

$ lsmod | wc -l
67

To see the variety of modules accessible on the system (not simply operating), do that command:

$ modprobe -c | wc -l
41272

Different instructions for inspecting modules

Linux gives a number of instructions for itemizing, loading and unloading, inspecting, and checking the standing of modules.

  • depmod — generates modules.dep and map information
  • insmod — a easy program to insert a module into the Linux Kernel
  • lsmod — present the standing of modules within the Linux Kernel
  • modinfo — present details about a Linux Kernel module
  • modprobe — add and take away modules from the Linux Kernel
  • rmmod — a easy program to take away a module from the Linux Kernel

Itemizing modules which might be in-built

As talked about above, the lsmod command is essentially the most handy command for itemizing modules. There are, nevertheless, different methods to look at them. The modules.builtin file lists all modules which might be constructed into the kernel and is utilized by modprobe when making an attempt to load certainly one of these modules. Word that $(uname -r) within the instructions under gives the identify of the kernel launch.

$ extra /lib/modules/$(uname -r)/modules.builtin | head -10
kernel/arch/x86/crypto/crc32c-intel.ko
kernel/arch/x86/occasions/intel/intel-uncore.ko
kernel/arch/x86/platform/intel/iosf_mbi.ko
kernel/mm/zpool.ko
kernel/mm/zbud.ko
kernel/mm/zsmalloc.ko
kernel/fs/binfmt_script.ko
kernel/fs/mbcache.ko
kernel/fs/configfs/configfs.ko
kernel/fs/crypto/fscrypto.ko

You may get some extra element on a module through the use of the modinfo command, although nothing that qualifies as a straightforward clarification of what service the module gives. The omitted particulars from the output under embrace a prolonged signature.

$ modinfo floppy | head -16
filename: /lib/modules/5.0.0-13-generic/kernel/drivers/block/floppy.ko
alias: block-major-2-*
license: GPL
writer: Alain L. Knaff
srcversion: EBEAA26742DF61790588FD9
alias: acpi*:PNP0700:*
alias: pnp:dPNP0700*
relies upon:
retpoline: Y
intree: Y
identify: floppy
vermagic: 5.0.0-13-generic SMP mod_unload
sig_id: PKCS#7
signer:
sig_key:
sig_hashalgo: md4

You’ll be able to load or unload a module utilizing the modprobe command. Utilizing a command just like the one under, you possibly can find the kernel object related to a specific module:

$ discover /lib/modules/$(uname -r) -name floppy*
/lib/modules/5.0.0-13-generic/kernel/drivers/block/floppy.ko

Should you wanted to load the module, you may use a command like this one:

$ sudo modprobe floppy

Wrap-up

Clearly the loading and unloading of modules is an enormous deal. It makes Linux programs significantly extra versatile and environment friendly than in the event that they ran with a one-size-fits-all kernel. It additionally means you can also make vital adjustments — together with including {hardware} — with out rebooting.

Be a part of the Community World communities on

Fb

and

LinkedIn

to touch upon subjects which might be prime of thoughts.

Supply

Germany Devoted Server

Leave a Reply