You are not logged in.

#1 2026-01-05 21:50:11

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 246

detect-firmware.sh - Script to determine required firmware packages

Hello,

I've made a little bash script to check which firmware packages are required on the system.

Aside from pacman and bash shell it requires pkgfile installed and initialized.

Available from her:
https://codeberg.org/GerBra/detect_firmware

(My english is not "the yellow from the egg" <g>, please be patient.)

Thanks!

Last edited by GerBra (2026-01-05 21:51:07)


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#2 2026-01-06 07:02:21

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,477
Website

Re: detect-firmware.sh - Script to determine required firmware packages

Thanks for the script.

One thing that caught my eye is, that the "--no-spinner" parameter is possibly superfluous if the script would check whether STDOUT/STDERR are TTYs.
Also the docs name it "--no-spinner", but the actually checked-for parameter is "--no_spinner".


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#3 2026-01-06 11:10:41

augofeta
Member
Registered: 2025-07-29
Posts: 5

Re: detect-firmware.sh - Script to determine required firmware packages

Or if you are in a hurry, this one-liner does not need pkgfile, only base:

pacman -F $(modinfo -F firmware $(lsmod | cut -d' ' -f1) 2>/dev/null | sed -e 's,^,/usr/lib/firmware/, ; s,$,.zst,' ) | sed -e 's,^.* owned by core/,pacman -Q ,;' | cut -d' ' -f1-3 | sort -u | bash -

It shows in error the firmware packages your system is missing. Thanks!

Offline

#4 2026-01-06 11:27:43

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,623

Re: detect-firmware.sh - Script to determine required firmware packages

Looks good, maybe mention it on the linux firmware wiki page ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2026-01-06 14:24:49

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 246

Re: detect-firmware.sh - Script to determine required firmware packages

schard wrote:

... if the script would check whether STDOUT/STDERR are TTYs.

Very good idea! Thanks, i have implemented this now. //Edit: and removed this as an option, so the misspelled parameter is no more a problem for this world... <g>

@augofeta
Users with other locale should use your oneliner with LANG=C prefixed. (Also the tailing piped bash)

You iterate over all firmware files on a module. This was also my first approaches. But this is not necessary and VERY time intensive.
//Edit: See: https://codeberg.org/GerBra/detect_firmware/issues/4


augofeta wrote:

... does not need pkgfile

Also why i switched from pacman -F/-Fx to pkgfile:
pkgfile is massive faster and needs massive lesser ressources(memory,cpu).
pacman -F is good for a single (or few) searches. But when to have doing a LOT of queries it "sucks¹". If you need -Fx, it "sucks more¹"...

Take this two modules for example: r8169 and amdgpu
I replaced the lsmod part from your oneliner to use modinfo only on above module.
Also i show you only the first part, until the first pipe(sed): //Edit: I mean: the times based on your full oneliner, i show only the first part of this

$ modinfo -F firmware r8169 | wc -l
26 
# pacman -F
$ time LANG=C pacman -F $(modinfo -F firmware r8169 2>/dev/null 
linux-firmware-realtek 20251125-2
#
real	0m1,935s (26 x pacman -F)

# pkgfile
$ time LANG=C pkgfile $(modinfo -F firmware r8169 2>/dev/null
bash: Zeile 1: core/linux-firmware-realtek: Datei oder Verzeichnis nicht gefunden
# don't have looked why this not worked with your oneliner, but it
# happens after pacman -F part/pipe, in pacman -Q, so the time is realistic
# //Edit: it's the repo part, pacman -Q match only on package names.
#
real	0m0,085s (26 x pkgfile)

# pacman -Fx
$ time LANG=C pacman -Fx $(modinfo -F firmware r8169 2>/dev/null
linux-firmware-realtek 20251125-2
#
real	0m39,508s (26 x pacman -Fx)

Now take a module with a lot of firmware files, ex. amdgpu (there a others: nouveau,radeon,...)

$ modinfo -F firmware amdgpu | wc -l
670
# pacman -F
$ time LANG=C pacman -F $(modinfo -F firmware amdgpu 2>/dev/null
Fehler: Paket »linux-firmware-amdgpu« wurde nicht gefunden
#
real	0m6,308s (670 x pacman)

# pkgfile
$ time LANG=C pkgfile $(modinfo -F firmware amdgpu 2>/dev/null
#
real	0m0,119s (670 x pkgfile)

# pacman -Fx
$ time LANG=C pacman -Fx $(modinfo -F firmware amdgpu 2>/dev/null
Fehler: Paket »linux-firmware-amdgpu« wurde nicht gefunden
#
real	16m17,840s (670 x pacman -Fx) !!!!!!!!!!!!

¹ https://bbs.archlinux.org/viewtopic.php?id=311375

Last edited by GerBra (2026-01-06 14:47:58)


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

#6 2026-01-10 11:05:03

GerBra
Forum Fellow
From: Bingen/Germany
Registered: 2007-05-10
Posts: 246

Re: detect-firmware.sh - Script to determine required firmware packages

Some news: V4.3

- Same firmware files found in different repository packages are now handled
If the user has additional (e.g. 3rd-party repositories) enabled in
pacman.conf a searched firmware file could be found in different
packages from these. We now honor this by displaying these firmware
packages as an alternative either in module and summary output. The
order of alternatives are based on pacman's repository order.
This requires know pacconf from pacutils package.

- If dynamic debugging on firmware loading is active (according to https://wiki.archlinux.org/title/Linux_ … _firmware) the journal output is now displayed.
//Edit: There was a bug on detecting an active boot parameter, so the message was always displayed (incomplete). This is fixed in current git repo version.

- a PKGBUILD is provided in source repo folder archlinux

A sample output from my PC:
https://0x0.st/PXPc.txt

Last edited by GerBra (Yesterday 07:04:39)


My avatar: "It's not just a toilet... a FERGUSON. The King of bowls. Sit down and give me your best shot." Al Bundy

Offline

Board footer

Powered by FluxBB