initrd, and modules.

So, I’ve looked into this a bit myself, and have mostly run into a brick wall. What is the best way to remove modules from the initial ram disk, and then keep the initrd from putting future kernel module into it ?

It,s a bit of a pain in the arse that blacklisting modules does not work, and in fact the only thing I have found to work is something like:

touch /etc/modprobe.d/g_ether.conf && echo ‘install g_ether /bin/true’ > /etc/modprobe.d/g_ether.conf

Seems a bit of a hack. . .

So, nothing ? Nada ? Zilch ?

Am I the only one that understands the point of using kernel modules, is to load these modules when, and only when you want / need them ? Not all the time ?

Ok . . . So here is the deal.

$ lsmod
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.

  1. Recompile the kernel, and deselect all this garbage, and just live without gadget drivers period.
  2. Recompile the kernel, and compile out initrd capability.
  3. Modify the initramfs, which seems complex, but doable ( still reading ).
  4. 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 . . .

#!/bin/sh

modules=$(lsmod|cut -d ’ ’ -f 1)
modpath="/etc/modprobe.d"
for module in $modules
do
if [ $module != ‘Module’ ] ; then
touch $modpath/$module.conf
echo ‘install ’ $module ’ /bin/true’ > $modpath/$module.conf
fi
done

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

Ok . . . So here is the deal.

$ lsmod
Module Size Used by
bnep 13297 2

rfcomm 52320 0
bluetooth 394459 10 bnep,rfcomm

connman in jessie does these two..

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

These get modprobe'd from /opt/scripts/boot/am335x_evm.sh

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 . . .

Regards,

Continued . .

$ cd /etc/modprobe.d/
$ sudo rm nfsd.conf
$ sudo rm uio.conf
$ sudo rm uio_pdrv_genirq.conf
$ sudo rm leds_gpio.conf

$ sudo reboot

$ lsmod
Module Size Used by
nfsd 220016 2
leds_gpio 3102 0
uio_pdrv_genirq 3313 0
uio 8350 1 uio_pdrv_genirq

*These get modprobe’d from /opt/scripts/boot/am335x_evm.*sh

Thanks for the reply Robert. Yeah, that was driving me insane( short trip ). Apparently I need an advanced class on grep, but I used grep as much as I could on the rootfs, and apparently missed that. However, I’m also using Wheezy 7.8 rootfs, and I went through your build guide again, found the 7.8 barefs, set it all up, and . . . somehow the file system, and boot loaders are all messed up.

As an example, the output from ttyO0 was largely garbled . . . However, I’m thinking that’s somehow my fault and not yours / your guides fault. Basically I just “ripped” the first and second stage boot loaders via dd . . . then added them with the 7.8 barefs + kernel I built.

Another issue I ran into . . .

ERROR: ld.so: object ‘libfakeroot-sysv.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘libfakeroot-sysv.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘libfakeroot-sysv.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘libfakeroot-sysv.so’ from LD_PRELOAD cannot be preloaded: ignored.

Over, and over, and over when running ./build_deb.sh. Initially I took this literally, as an error. Later, as in this morning I found some obscure post on one of the original beagleboards, where the person says it’s just an annoyance related to 32bit compiler, and 64bit fakeroot. So, I let the script run out, and the deb works fine. I wonder if it would be a good idea to just pipe stderror to /dev/null when that script is running ?

Anyway, looking into /opt/scripts . . .

ah . . .

#In a single partition setup, dont load g_multi, as we could trash the linux file system…
if [ “x${root_drive}” = “x/dev/mmcblk0p1” ] || [ “x${root_drive}” = “x/dev/mmcblk1p1” ] ; then
#serial:
#modprobe g_serial || true
#Make sure (# CONFIG_USB_ETH_EEM is not set), otherwise this shows up as “usb0” instead of ethX on host pc…
modprobe g_ether iSerialNumber=${SERIAL_NUMBER} iManufacturer=Circuitco iProduct=BeagleBone${BLACK} host_addr=${cpsw_1_mac} || true
else
boot_drive="${root_drive%?}1"
modprobe g_multi file=${boot_drive} cdrom=0 ro=0 stall=0 removable=1 nofua=1 iSerialNumber=${SERIAL_NUMBER} iManufacturer=Circuitco iProduct=BeagleBone${BLACK} host_addr=${cpsw_1_mac} || true
fi

Robert,

cmdline=ipv6.disable=1

In /boot/uEnv.txt seems to shave a good bit of boot time off at system up, on Wheezy 7.8 rootfs, systemd disabled, and . . .

$ uname -r
4.1.12-bone-rt-r16

I built that kernel myself using your guide, and origin/am33x-rt-v4.1 -b tmp-rt, but using the stock .config. Just figured I’d let you know in case the subject every comes up.

Commenting out the line bolded a couple posts back did the trick :slight_smile:

That's interesting..

So debian's config defaults to: CONFIG_IPV6=Y

The only real use case of that built-in, root_nfs on an ipv6, but then
you'd always have ipv4...

but we had that by default in 3.8..

https://github.com/beagleboard/linux/blob/dc982e80db34b0448c91ae1597ef38a3f4a95e35/arch/arm/configs/bb.org_defconfig#L669

darn... here i though we found the speed regression. :wink:

Regards,

I can not exactly tell how much of a difference it is, but I want to say between 5-10 seconds. If systemd was enabled I could do a perf test, but . . . heh