After discovering that the Ubuntu wiki I am using is referring to external modules, it was easier to find a solution by rtfm.
Summary of external modules install paths
- External modules are installed with
modules_install
at /lib/modules/$(KERNELRELEASE)/extra/
by default.
- When installing external modules elsewhere,
INSTALL_MOD_PATH
is used to prefix the installation path, or INSTALL_MOD_DIR
is used to create a new directory under the usual /lib/modules/$(KERNELRELEASE)
path.
See the bottom of this answer for more detailed explanation.
Searching for external modules
To narrow the search down to the above, I'm using locate
to print paths containing lib/module
and xargs
to filter the output of paths that are not directories.
Lastly, grep -v
is used to filter the output of a paths beginning with /lib/modules/$(uname -r)/kernel
. This should still display paths that were prefixed using INSTALL_MOD_PATH
during installation, for example /frodo/lib/modules/$(KERNELRELEASE)/kernel/
.
This obviously won't print the path of modules that were somehow installed in a completely weird path. Here is the command:
locate --null "*lib/modules/$(uname -r)*" | xargs -r0 sh -c 'for i do [ -d "$i" ] && printf "%s\n" "$i"; done' sh {} + | grep -v "^/lib/modules/$(uname -r)/kernel\|^/lib/modules/$(uname -r)$\|^/lib/modules/$(uname -r)/build$\|^/lib/modules/$(uname -r)/initrd$"
This prunes the in-tree paths from the output, which for me was 4695 lines when using only locate "*lib/modules/$(uname -r)*"
. Now the output is much less and should only display known out-of-tree paths:
/frodo/lib/modules/3.12.3-031203-generic
/frodo/lib/modules/3.12.3-031203-generic/kernel
Excerpts from documentation Building External Modules
The details below are from Building External Modules
modules_install
Install the external module(s). The default location is
/lib/modules/<kernel_release>/extra/, but a prefix may
be added with INSTALL_MOD_PATH (discussed in section 5).
=== 5. Module Installation
Modules which are included in the kernel are installed in the
directory:
/lib/modules/$(KERNELRELEASE)/kernel/
And external modules are installed in:
/lib/modules/$(KERNELRELEASE)/extra/
--- 5.1 INSTALL_MOD_PATH
Above are the default directories but as always some level of
customization is possible. A prefix can be added to the
installation path using the variable INSTALL_MOD_PATH:
$ make INSTALL_MOD_PATH=/frodo modules_install
=> Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/
INSTALL_MOD_PATH may be set as an ordinary shell variable or,
as shown above, can be specified on the command line when
calling "make." This has effect when installing both in-tree
and out-of-tree modules.
--- 5.2 INSTALL_MOD_DIR
External modules are by default installed to a directory under
/lib/modules/$(KERNELRELEASE)/extra/, but you may wish to
locate modules for a specific functionality in a separate
directory. For this purpose, use INSTALL_MOD_DIR to specify an
alternative name to "extra."
$ make INSTALL_MOD_DIR=gandalf -C $KDIR \
M=$PWD modules_install
=> Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/