Removing unneeded modules - OpenWRT 21.02.2

Hello:

I have recently installed OpenWRT 21.02.2 to a 1Tb WD-MyBook Live.
Still getting acquainted as embedded type OSs are a new thing for me.

But I'm quite pleased with this firmware.
It has enabled me to use this old hardware for something useful.
ie: a very basic NAS to back up back ups, so to speak.

To think I spent over US$40 on a RPi3+ with no drive ...
But I digress ...

While looking at the installed packages I see these:

kmod-scsi-core 5.4.179-1  ~984 B
kmod-usb-core 5.4.179-1  ~120.0 KB
kmod-usb-dwc2 5.4.179-1  ~60.9 KB
kmod-usb-ledtrig-usbport 5.4.179-1  ~4.5 KB
kmod-usb-storage	5.4.179-1  ~27.3 KB

The thing is that this board does not have a SCSI or USB controller.
The only available port is 100/1000 Ethernet.

The only thing that can apparently be used, albeit with some surgery, is a UART port to connect the board to a PC via a USB to UART cable, not sure how useful it would be.

I understand that kernel modules are not automatically loaded in OpenWRT but have to be explicitly loaded.

/etc/modules.d has these modules listed:

20-usb-core
40-scsi-core
50-usb-ledtrig-usbport
54-usb-dwc2
usb-storage

/etc/modules-boot.d has these modules listed:

@ 20-usb-core
@ 40-scsi-core
@ 54-usb-dwc2
@ usb-storage

ie: 54-usb-dwc2 is not there.

The question is:

Can these kernel modules be safely removed from the system without altering system dependencies?

I would not want to render the board unbootable and have to fix what went wrong by taking it apart again to pop the drive into my box to acess it.

Thanks in advance.

Best.

PCL

Before removing the modules, check that they are not used

for example on my router with a ssd attached
i get

lsmod
scsi_mod 81920 3 uas, usb_storage, sd_mod

so for me they are necessary

if you can do
rmmod usb-storage
without losing access to the 1Tb drive
then maybe and i say maybe you could remove them but to recover only 200Kb

if i were you i wouldn't do it ...

1 Like

+1

Chances are that they were installed as dependencies for other packages. The only reason to actually worry about this is if you are running out of space on your OpenWrt's RW partition.

1 Like

If it not broke, don't fix it! You obviously spent some time getting OpenWrt on your device and I KNOW how great this feeling is.

I just recently rejoined the forum to get some assistance on a MikroTik router...but I digress.

Since 2015~ish I've had this PogoPlug running and I throw everything at this NAS. It has a tinny bit of free space left.

Hostname	PINK
Model	Pogoplug v4
Firmware Version	OpenWrt Chaos Calmer 15.05 / LuCI (git-15.248.30277-3836b45)
Kernel Version	3.18.20
Local Time	Thu Apr 14 16:45:23 2022
Uptime	79d 17h 24m 49s
Load Average	


Total Available	
6196 kB / 125448 kB (4%)
Free	
2124 kB / 125448 kB (1%)
Buffered	
4072 kB / 125448 kB (3%)

I wouldn't even look at it cross-eyed, even tho I'm cross-eyed!

Hello:

Of course.

But it is not about the module's size.
It is about their being loaded without being any need for them to be and taking up memory.

This is the data I have found using modinfo:

~# modinfo usb-common
module:		/lib/modules/5.4.179/usb-common.ko
license:	GPL
depends:	
intree:		Y
name:		usb_common
vermagic:	5.4.179 mod_unload 
~#

usb-comon has no dependencies.
But usbcore is a dependency:

root@owrtbook:~# modinfo usbcore
module:		/lib/modules/5.4.179/usbcore.ko
license:	GPL
depends:	usb-common
intree:		Y
name:		usbcore
vermagic:	5.4.179 mod_unload 
root@owrtbook:~# 

And usb-storage depends on usbcore:

~# modinfo usb-storage
module:		/lib/modules/5.4.179/usb-storage.ko
license:	GPL
depends:	usbcore
intree:		Y
name:		usb_storage
vermagic:	5.4.179 mod_unload 
~# 

As well as ledtrig_usbport:

~# modinfo ledtrig-usbport
module:		/lib/modules/5.4.179/ledtrig-usbport.ko
license:	GPL v2
depends:	usbcore
intree:		Y
name:		ledtrig_usbport
vermagic:	5.4.179 mod_unload 
~# 

And dwc2:

~# modinfo dwc2
module:		/lib/modules/5.4.179/dwc2.ko
license:	Dual BSD/GPL
license:	Dual BSD/GPL
depends:	usbcore,usb-common
intree:		Y
name:		dwc2
vermagic:	5.4.179 mod_unload 
~# 

Which also depends on usb-common.

So ...

usb_common --> dwc2, usbcore
usbcore --> ledtrig_usbport, usb_storage, dwc2

Finally:

ledtrig_usbport --> none
dwc2 --> none

It's all between these USB modules.

But I have found no data on scsi-core.
I'll have to do more reading.

Thanks to all for your input.

Best,

PCL

So the question would be is taking the risk of this outcome worth the perceived "benefit" of removing the modules...

To see what's using memory, and how much, either install...

htop and run it from the CLI

...or...

install sysstat and run -

pidstat -r -p ALL 2 (which snapshots every 2 seconds)

To log the results (name the file whatever you want) -

pidstat -r -p ALL 2 | tee -a Memtrace.txt

CTRL-C to end the trace.

Log file will be in the root directory.

You could also build the firmware yourself, and only include the necessary modules to run a bare-minimum installation.

Hello:

I would like to avoid the hassle of borking the OpenWRT install by learning to do it properly the first time around but it would be no big deal.

But the modules will not be removed as the drive space they use will not be available.

What I want to do is simply not load the unneeded modules.

OpenWRT is an embedded OS for routers, it was certainly not written for hardware such as the My Book Live. I chose it because I was not able to find a suitable replacement for the original firmware. ie: because it adapted quite well to this old, inexpensive but quite capable hardware and is current/maintained.

I'm just trying to tweak it, so to speak.

You could also build the firmware ...

Of course, but that would be a hassle.
I would have to build it every time an upgrade is released.

I want to do this as I do it in my Linux boxes.
ie: unload/blacklist a kernel module to save memory/CPU cycles

Lacking apt and aptitude and familiarity with OpenWRT, it is a bit harder.

Just have to find the proper dependency information.

I'll try your suggestions.

Thanks for your input.

Best,

PCL