Start out by creating a little shell script to compare two runs of ‘lsmod’;
#!/bin/bash
# ~/bin/ModList
File1=/tmp/ModList.a
File2=/tmp/ModList.b
# If there is no File1, create it
[ ! -e ${File1} ] && lsmod > ${File1}
# Always create File2
lsmod > ${File2}
# Compare File1 with File2, results to the screen
diff -i ${File1} ${File2}
# Set EL to the errorlevel of the previous diff command
# If there were differences, this will not be zero
EL=$?
# If there were differences, replace File1 with File2
[ ${EL} ] && mv ${File2} ${File1}
Save the file, make it executable with
chmod a+x ~/bin/ModList
Then, in a terminal (possibly from another machine) run this command;
watch -n 30 ~/bin/ModList
After that, every thirty seconds, the script compares what’s currently loaded with what was loaded previously, and if there is a difference, prints it to the screen and saves the new state as the default state.
Every 30.0s: ./ModList cili6996.stevejonescomputers.com: Fri Oct 14 12:16:52 2022
83,84c83,84
< nvidia 35307520 335 nvidia_modeset
< snd_hda_intel 49152 5
---
> nvidia 35307520 318 nvidia_modeset
> snd_hda_intel 49152 10
92c92
< rfkill 28672 4 hp_wmi
---
> rfkill 28672 2 hp_wmi
103c103
< snd_pcm 118784 10 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,soundwire_intel,snd_sof,snd_sof_intel_hda_common,snd_compress,snd_soc_core,snd_soc_skl,snd_hda_core
---
> snd_pcm 118784 11 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,soundwire_intel,snd_sof,snd_sof_intel_hda_common,snd_compress,snd_soc_core,snd_soc_skl,snd_hda_core
110c110
< snd 94208 24 snd_hda_codec_generic,snd_seq,snd_hda_codec_conexant,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_timer,snd_compress,snd_soc_core,snd_pcm
---
> snd 94208 33 snd_hda_codec_generic,snd_seq,snd_hda_codec_conexant,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_timer,snd_compress,snd_soc_core,snd_pcm
133c133
< fuse 155648 3
---
> fuse 155648 1
In the listing above, the nvidia and snd_hda_intel drivers went from being used by 335 and 5 objects to 318 and ten objects. rfkill went from 4 objects to 2, and snd_pcm from 10 to 11 objects (driver objects in this case). snd needed to gain 9 driver objects, and fuse lost 2. The 83,84c83,84 near the top are offsets in the file for the data and can be ignored for the most part.
Press Ctrl-C when you have gotten the information you need.