3

I'm attempting to upgrade and test kernel 3.12.

What is the most efficient way to identify out-of-tree modules that should be removed before testing?

There are a few mentioned (vitualbox, nvidia, fglrx, bcmwl), but is there a way to identify installed modules that are considered out-of-tree?

1

Kernel modules, whether in-tree or out-of-tree, are installed in directories specific to given kernel versions (/lib/modules/$(uname -r)), so you shouldn't need to clean up modules to upgrade to a new kernel: the new kernel simply won't consider the old modules.

Nevertheless, as far as I'm aware in-tree modules go in /lib/modules/$(uname -r)/kernel, so anything in /lib/modules/$(uname -r) outside of that is an out-of-tree module.

  • I was getting a "bad return status" error due to virtualbox. I guess that's one way to find out. Worked find after removing it. – iyrin Apr 17 '15 at 6:14
0

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.