The kernel itself is usually “/boot/Image
” (that’s an uncompressed kernel; lots of compressed variants exist, but usually in “/boot
”). It is this file which determines the output of “uname -r
”. And it is the output of “uname -r
” which always determines the subdirectory of “/lib/modules/
” to search for that kernel’s modules.
If you installed a kernel Image
(preferably with some edited name like “Image-gadget
”), then then actual name of the Image
file will never have an effect on where that Image
looks. The location is more or less hard coded into the Image
at the time of compile, just as is the “uname -r
”. If you used CONFIG_LOCALVERSION
as “-gadget
”, and if the installed kernel searches another location, then you are guaranteed that your kernel is not the one booting.
The simplest case is if the entire filesystem is a single ext4
partition. This implies that if Image
has an ext4
driver integrated into it (and the default kernels do), then you can always access modules both in “/boot
” and in “/lib/modules/$(uname -r)/
”.
The next step to complicate this is if you have a different “/boot
” partition versus the partition where “/lib/modules/
” is found. Now if you have a separate boot (“/boot
”) and rootfs (“/
”, which contains “/lib/modules/
”), then it is rare to have any issue. Sometimes if a separate disk is involved, then the driver for the disk controller itself might mean that the Image
can’t mount “/lib/modules/
”, but this wouldn’t be due to lacking ext4
. What I’m trying to illustrate is that there is a chain of drivers required to access “/lib
” (and thus also “/lib/modules
”), and if anything in the chain is missing, then modules are not accessible. It follows that if both “/boot
” and “/
” are the same ext4
partition, that the ability to load the kernel already guarantees the ability to find modules (and if the modules are valid, then to load those modules).
Here is the real reason I mention all of that detail: It is common in the Linux world to boot the Image
from some simple device, but then to put everything else on some more complicated device. An example is using /boot
as ext4
, but using some other filesystem type on “/
” (e.g., XFS filesystem is common for large file multi-media systems). The kernel would not be able to mount an XFS “/
” to find its own modules if the XFS is itself in the form of a module. You end up with the proverbial “chicken and the egg” dilemma. Thus an initial ramdisk was created as a generic adapter.
An initrd (initial ramdisk) is just a very simple filesystem that lives entirely in RAM. All Linux bootloaders and boot chains that I know of understand ext4
and initrd
by default. If your Image
is on ext4
of “/boot
”, then the bootloader executes this; if the early “/
” (which includes the init
script and module directory “/lib/modules/$(uname -r)
”) is an initrd
with the XFS or RAID or volume manager or disk controller drivers, then the Image
will have access to those modules regardless of the feature being in the form of a module. A small subset of boot-critical modules are very often placed in that initrd
, and then modules can be found. Once modules are loaded, then the init
process that run from the initrd
will perform a pivot of the root device to change “/
” from being the initrd
" to “/
” instead referring to the actual disk device. Doing so implies you no longer have to have the “/
” device drivers in the kernel Image
itself.
I suspect that if your kernel is not using the “uname -r
” which you altered this to be (the “-gadget
” version), then the Image
you think is loading is not actually loading.
I suspect that if your kernel is using the proper “uname -r
”, but it is failing to find modules which are installed to the new “/lib/modules/$(uname -r)/
” location, then it might be due to an initrd
not being set up to contain the new modules it needs.
Installing a module which is not required for boot implies you never need to put that module in the initrd
. Installing a module related to boot implies you must modify the initrd
to put any modules needed for boot into the new “/lib/modules/$(uname -r)/
”.
If you have modified the original Image
, and changes occur which go beyond adding only modules, then you should consider that you need to install all modules again to be sure they are compatible with this new kernel config (otherwise they might be found, and yet still fail to load). If the original initrd
is used (and your boot might not use an initrd
), this new kernel Image
means not only do you need to install modules into “/lib/modules/$(uname -r)
”, you must also install some of them to the initrd
.
Does your boot use an initrd
(initial ramdisk)? Look in “/boot/extlinux/extlinux.conf
”. Specifically, look in the boot entry for that Image
, and see if a file is listed in the key/value pair “INITRD
”, e.g., maybe it shows “INITRD /boot/initrd
”. If so, and if there are modules it fails to load from the new “/lib/modules/$(uname -r)/
”, and if the failed modules result in something going wrong during boot, then you have to add the new modules to the initrd
to complete the new kernel install.
Also, what is the exact response to the command “uname -r
”?