Last active
July 15, 2025 13:38
-
-
Save omid/4bee9bfc838d3a3b0c6febc42c74ed8f to your computer and use it in GitHub Desktop.
Script to Identify Unused linux-firmware-* Packages on Arch Linux (Use at your own risk)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #set -x | |
| # Help text for each firmware package | |
| declare -A FW_HELP=( | |
| [linux-firmware-radeon]="Firmware for ATI Radeon GPUs" | |
| [linux-firmware-amdgpu]="Firmware for AMD Radeon GPUs" | |
| [linux-firmware-intel]="Firmware for Intel graphics, WiFi, Bluetooth" | |
| [linux-firmware-nvidia]="Firmware for NVIDIA GPUs" | |
| [linux-firmware-broadcom]="Firmware for Broadcom and Cypress network adapters" | |
| [linux-firmware-atheros]="Firmware for Atheros WiFi and Bluetooth asapters" | |
| [linux-firmware-realtek]="Firmware for Realtek devices (WiFi, Bluetooth, Audio and so on)" | |
| [linux-firmware-mediatek]="Firmware for MediaTek and Ralink devices (WiFi, Bluetooth, Audio and so on)" | |
| [linux-firmware-cirrus]="Firmware for Cirrus Logic audio devices" | |
| [linux-firmware-whence]="Metadata and shared firmware support (always required)" | |
| [linux-firmware-other]="Unsorted firmware for various devices" | |
| ) | |
| # Commonly useful firmware packages even if not explicitly matched | |
| RECOMMENDED_FW=( | |
| linux-firmware-realtek | |
| linux-firmware-broadcom | |
| linux-firmware-atheros | |
| linux-firmware-mediatek | |
| linux-firmware-other | |
| ) | |
| # Define search keywords and associated firmware packages | |
| declare -A KEYWORD_TO_FW=( | |
| [amd]="linux-firmware-amdgpu" | |
| [radeon]="linux-firmware-radeon" | |
| [ati]="linux-firmware-radeon" | |
| [intel]="linux-firmware-intel" | |
| [nvidia]="linux-firmware-nvidia" | |
| [broadcom]="linux-firmware-broadcom" | |
| [atheros]="linux-firmware-atheros" | |
| [realtek]="linux-firmware-realtek" | |
| [mediatek]="linux-firmware-mediatek" | |
| [intel]="linux-firmware-intel" | |
| [cirrus]="linux-firmware-cirrus" | |
| ) | |
| # Collect hardware info (lowercase) | |
| HARDWARE=$( (lspci; lsusb) | tr '[:upper:]' '[:lower:]' ) | |
| # Track matches | |
| declare -A NEEDED_FW | |
| declare -A MATCHES | |
| # Match keywords against hardware output | |
| for keyword in "${!KEYWORD_TO_FW[@]}"; do | |
| if echo "$HARDWARE" | grep -q "\W$keyword\W"; then | |
| fw="${KEYWORD_TO_FW[$keyword]}" | |
| NEEDED_FW["$fw"]=1 | |
| MATCHES["$fw"]+="$keyword " | |
| fi | |
| done | |
| # Always needed | |
| NEEDED_FW["linux-firmware-whence"]=1 | |
| # Show installed firmware packages | |
| INSTALLED_FW=$(pacman -Q | grep '^linux-firmware-' | awk '{print $1}') | |
| echo | |
| echo "📦 Installed linux-firmware packages:" | |
| echo "$INSTALLED_FW" | |
| echo | |
| echo "✅ Suggested firmware packages to keep:" | |
| for fw in "${!NEEDED_FW[@]}"; do | |
| printf " %-25s %s\n" "$fw" "${FW_HELP[$fw]}" | |
| done | |
| echo | |
| echo "💡 Recommended firmware packages to keep:" | |
| for fw in "${RECOMMENDED_FW[@]}"; do | |
| if [[ -z "${NEEDED_FW[$fw]}" && "$INSTALLED_FW" =~ $fw ]]; then | |
| printf " %-25s %s\n" "$fw" "${FW_HELP[$fw]}" | |
| fi | |
| done | |
| echo | |
| echo "❌ Possibly unused firmware packages:" | |
| for fw in $INSTALLED_FW; do | |
| if [[ -z "${NEEDED_FW[$fw]}" ]]; then | |
| # Skip if it's in the recommended list | |
| skip=0 | |
| for rec in "${RECOMMENDED_FW[@]}"; do | |
| [[ "$fw" == "$rec" ]] && skip=1 && break | |
| done | |
| [[ $skip -eq 1 ]] && continue | |
| printf " %-25s %s\n" "$fw" "${FW_HELP[$fw]}" | |
| fi | |
| done | |
| echo |
Author
@cyanescent Thanks for the output.
I updated the script, now it suggests keeping both in your case (based on amd, ati and radeon keywords).
I added some help texts for each firmware and also recommendation for packages to keep (even when unused)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ (lspci; lsusb) | tr '[:upper:]' '[:lower:]'
00:00.0 host bridge: advanced micro devices, inc. [amd] renoir/cezanne root complex
00:00.2 iommu: advanced micro devices, inc. [amd] renoir/cezanne iommu
00:01.0 host bridge: advanced micro devices, inc. [amd] renoir pcie dummy host bridge
00:01.2 pci bridge: advanced micro devices, inc. [amd] renoir/cezanne pcie gpp bridge
00:01.3 pci bridge: advanced micro devices, inc. [amd] renoir/cezanne pcie gpp bridge
00:02.0 host bridge: advanced micro devices, inc. [amd] renoir pcie dummy host bridge
00:02.4 pci bridge: advanced micro devices, inc. [amd] renoir/cezanne pcie gpp bridge
00:08.0 host bridge: advanced micro devices, inc. [amd] renoir pcie dummy host bridge
00:08.1 pci bridge: advanced micro devices, inc. [amd] renoir internal pcie gpp bridge to bus
00:08.2 pci bridge: advanced micro devices, inc. [amd] renoir internal pcie gpp bridge to bus
00:14.0 smbus: advanced micro devices, inc. [amd] fch smbus controller (rev 51)
00:14.3 isa bridge: advanced micro devices, inc. [amd] fch lpc bridge (rev 51)
00:18.0 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 0
00:18.1 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 1
00:18.2 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 2
00:18.3 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 3
00:18.4 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 4
00:18.5 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 5
00:18.6 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 6
00:18.7 host bridge: advanced micro devices, inc. [amd] renoir device 24: function 7
01:00.0 network controller: intel corporation wi-fi 6 ax200 (rev 1a)
02:00.0 ethernet controller: realtek semiconductor co., ltd. rtl8111/8168/8211/8411 pci express gigabit ethernet controller (rev 15)
03:00.0 non-volatile memory controller: micron technology inc 2300 nvme ssd [santana]
04:00.0 vga compatible controller: advanced micro devices, inc. [amd/ati] renoir [radeon vega series / radeon vega mobile series] (rev c6)
04:00.1 audio device: advanced micro devices, inc. [amd/ati] renoir radeon high definition audio controller
04:00.2 encryption controller: advanced micro devices, inc. [amd] family 17h (models 10h-1fh) platform security processor
04:00.3 usb controller: advanced micro devices, inc. [amd] renoir/cezanne usb 3.1
04:00.4 usb controller: advanced micro devices, inc. [amd] renoir/cezanne usb 3.1
04:00.5 multimedia controller: advanced micro devices, inc. [amd] audio coprocessor (rev 01)
04:00.6 audio device: advanced micro devices, inc. [amd] family 17h/19h/1ah hd audio controller
05:00.0 sata controller: advanced micro devices, inc. [amd] fch sata controller [ahci mode] (rev 81)
05:00.1 sata controller: advanced micro devices, inc. [amd] fch sata controller [ahci mode] (rev 81)
bus 001 device 001: id 1d6b:0002 linux foundation 2.0 root hub
bus 001 device 002: id 04f2:b71a chicony electronics co., ltd integrated ir camera
bus 001 device 003: id 05e3:0608 genesys logic, inc. hub
bus 001 device 004: id 0bda:0129 realtek semiconductor corp. rts5129 card reader controller
bus 001 device 005: id 8087:0029 intel corp. ax200 bluetooth
bus 002 device 001: id 1d6b:0003 linux foundation 3.0 root hub
bus 003 device 001: id 1d6b:0002 linux foundation 2.0 root hub
bus 004 device 001: id 1d6b:0003 linux foundation 3.0 root hub