0

So today I learned that my distro's linux-unfree-firmware package is 491 Mb in size. I'm pretty sure my hardware doesn't need all of these files. Hence I think I can reduce this disk usage if I'll only know what files I can exclude from there.

Is there any official documentation, that states exactly what files from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/ are needed per device / computer model? Perhaps the official documentation of my Computer's hardware will state that? There's a Linux from scratch webpage that gives some info for popular hardware, but I'm wondering if there's a bit more "official" information available somewhere.

2 Answers 2

0

There is no "official" documentation for every piece of hardware there is and the firmware files that it requires, unfortunately. But, it is possible to know exactly what firmware files are needed by your hardware via hacking a bit on the Linux kernel build system.

More over, even if you do discover exactly what firmware files your hardware uses, you will get eventually a not-too-short list of files, that will need to be updated frequently - after pretty much every release (git tag) of https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/. This means that you won't be able to reliably filter out firmware files straight from the list that you'll soon learn to generate.

If you are still interested in this, follow this steps:

  1. Download the latest release of the kernel from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ .
  2. Run: make localmodconfig.
    • This will generate a .config file that will contain a list of build parameters according to your current kernel.
  3. Run make.
    • This will build the kernel, so it might take a while.
    • You'll might need to install some dependencies to make the build finish.
    • After make will finish, you'll have a bunch of .ko files which are kernel module files.
  4. Run this command:
find -name '*.ko' -exec modinfo {} \; | awk '$1 == "firmware:" { print $2}'

The last command prints a list of firmware files which will probably be found in your distro's linux-unfree-firmware package. These are the files your hardware needs.

Credits: https://lists.kernelnewbies.org/pipermail/kernelnewbies/2020-May/020818.html

0

For this task, I like the exhaustive/insider method described in this approach.
But then when running a generic & modular kernel already,
narrowing down installed firmware blobs list using modinfo like you suggested,
here is a quick and dirty way:

lsmod | cut -d ' ' -f 1 | tr '_' '?' | xargs -I % find /lib/modules/ -name "%.*" | xargs -I % modinfo % | awk '$1 == "firmware:" { print $2}'

this:

  1. Lists loaded modules
    (keep in mind any builtin kernel module that requires a firmware is left-out here)
  2. extract first column, and replace '_' in names with single-char wildcard,
    as often filenames will instead use '-'
  3. find said module-file, and hand in to modinfo
    to derive a list of firmware blobs like you suggested.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .