Ok . . . So here is the deal.
Module Size Used by
bnep 13297 2
rfcomm 52320 0
bluetooth 394459 10 bnep,rfcomm
usb_f_ecm 9505 1
g_ether 4794 0
usb_f_rndis 22459 2 g_ether
u_ether 11057 3 usb_f_ecm,usb_f_rndis,g_ether
libcomposite 43376 3 usb_f_ecm,usb_f_rndis,g_ether
nfsd 220016 2
evdev 7956 0
tda998x 11683 1
omap_aes 13033 0
omap_sham 19152 0
tilcdc 27869 0
omap_rng 4346 0
rng_core 7233 1 omap_rng
drm_kms_helper 106705 3 tda998x,tilcdc
uio_pdrv_genirq 3313 0
uio 8350 1 uio_pdrv_genirq
leds_gpio 3102 0
That’s a bit ridiculous especially considering I only use a few of those modules. nfsd obviously I use, but what has been on my nerves lately are all these gadget drivers I never use. Or even if I were to use them I would prefer to load them, or even just g_ether / g_serial as I need them. uio related modules do not bother me as I use those often enough, and leds_gpio . . . well I can take it or leave it. The rest, as far as I’m concerned need to go. The bluetooth modules, I would probably need to remove the bluetooth package to get rid of these, or fake install . . .
So there are a few options that I can think of.
- Recompile the kernel, and deselect all this garbage, and just live without gadget drivers period.
- Recompile the kernel, and compile out initrd capability.
- Modify the initramfs, which seems complex, but doable ( still reading ).
- Create conf files for all the modules I do not want running all the time, and insert a fake install . .
Anyway, I’m not an expert here, and would appreciate some feedback. Even a "hey dumbass, thats not how you do things, you do it like ". Documentation on the web in this regard is fairly sparse, and much of that is outdated. Short term though . . . I wrote a script to modprobe -r $module, and have since changed it around to “blacklist” these modules via fake install. It needs to be run with elevated privs of course, and one needs to manually remove the /etc/modprobe.d/*conf files they actually want running. Since the script is simple, and will blacklist every module that is loaded at the time it’s run . . .
modules=$(lsmod|cut -d ’ ’ -f 1)
for module in $modules
if [ $module != ‘Module’ ] ; then
echo ‘install ’ $module ’ /bin/true’ > $modpath/$module.conf
Ideal ? hardly . . .
$ ls /etc/modprobe.d/
blacklist fbdev-blacklist.conf uio.conf.bak
$ sudo ./remove-modules.sh
$ ls /etc/modprobe.d/
blacklist evdev.conf libcomposite.conf omap_sham.conf tilcdc.conf uio_pdrv_genirq.conf
bluetooth.conf fbdev-blacklist.conf nfsd.conf rfcomm.conf u_ether.conf usb_f_ecm.conf
bnep.conf g_ether.conf omap_aes.conf rng_core.conf uio.conf usb_f_rndis.conf
drm_kms_helper.conf leds_gpio.conf omap_rng.conf tda998x.conf uio.conf.bak
$ cat /etc/modprobe.d/g_ether.conf
install g_ether /bin/true