Moving lib/modules to separate partition

So i have an experimental setup where I use a separate partition that I mount for /lib/modules/*
This way i can only flash / update the kernel and the associated driver modules without root file system updates, however when I do this i dont see any modules when i run lsmod.

However all modules load fine if they are available on the root partition directly or If i manually load the drivers.

Now is there any way of making the partition that contains /lib/modules avilable at the same time as / partition and if not is there a script / command i can use to automatically load all required modules much like what the kernel does at the start

You should be able to list it in /etc/fstab so that the extra filesystem gets mounted at /lib/modules (note that this will obscure anything currently found at that path).

@danielt yes /etc/fastab already has this entry to load the partition for /lib/modules . The problem is that the mount is probably done much after the kernel modules install service is completed.

At what stage are they loading? Are they loaded from the initrd or the rootfs?

If /lib/modules is part of the rootfs then on boot running lsmod all the kernel modules are loaded for device detected.

If i mount another partition to /lib/modules in the rootfs and the mount is in /etc/fstab , then on boot running lsmod shows no module loaded .

The issue looks like the mount of the external partition occurs later than what ever init process loads the kernel on boot

AFAIK the hotplug events that provoke module loading are processed when udev starts up… you will need to make sure that the filesystem containing the modules are available at the point udev starts running.

1 Like

Thanks , ill try using systemd to mount the partition but before udev trigger -

I am hoping this should solve it ! Will let you know how it goes.

@danielt thanks , so got this to work. However I couldn’t get the partition to load before systemd-udev-trigger.service . So What i did was simply add another service that does sudo systemctl restart systemd-udev-trigger.service after the partition is mounted and this now loads all the drivers.

Great to hear you got this working… also that’s a nice little hack! I’ll see if I can remember this one, I suspect it could come in useful in the future.