Kernel firmware packages consume a lot of disk space on a Linux system, both on the installed system and in an installation environment (inst-sys). In some cases (e.g. RAM disk for a minimal NET ISO), that also means a lot of RAM usage.
The installed kernel-firmware packages on a Leap 15.5 (screenshot of qdirstat pkg:/kernel-firmware
)
Together, they consume more disk space than most of the largest packages of the system:
All installed packages on a Leap 15.5 development system
Yet most of those packages are largely unused; only those for which the hardware is actually present are really used. But there are caveats; see below.
In general, those firmware packages contain binary data that either needs to be uploaded to some piece of hardware, or (mostly hardware-specific) binary code that is not available as Open Source code.
In a few cases, it might also be binary-only codecs that cannot be distributed as source code.
Firmware binary files can be in any of those directories:
On SLE-15 SPx / Leap 15.x:
/lib/firmware
(directly without a subdirectory)/lib/firmware/<hardware-vendor-name>
(most common)/lib/firmware/<hardware-vendor-name>/<hardware-name>
On newer versions (Tumbleweed, ALP) after the usr-merge:
/usr/lib/firmware
(directly without a subdirectory)/usr/lib/firmware/<hardware-vendor-name>
(most common)/usr/lib/firmware/<hardware-vendor-name>/<hardware-name>
(The old /lib/firmware
paths are still valid because /lib
is a symlink to /usr/lib
)
Addendum by Takashi:
/lib/firmware
is treated as the root directory, and kernel tries to load from the/lib/firmware/updates/$VERSION
,/lib/firmware/updates
, and/lib/firmware/$VERSION
directories before/lib/firmware.
The firmware binary files are already compressed in the .xz
format.
Addendum by Takashi:
- Some files are intentionally left uncompressed; e.g. AMD CPU ucode or some small files that don't need compression.
- The all-in-one uncompressed package is planned to be renamed in future to kernel-firmware-compressed, so that it won't be used for OBS builds. Once after this rename, kernel-firmware-all will be used as kernel-firmware alias instead. The installer and other images can use the compressed / split packages as well. Tracked in bsc#1214789.
Package kernel-firmware is the monolithic legacy version before the package split, and before file compression was added to the kernel modules. That is why this package has an installed size of 874.2 (!) MB.
This package is not installed by default, but it is used in the YaST inst-sys.
To check with Steffen: Is this really true? Could we also use the split and compressed ones to save disk space? Would it even save disk space, or is the inst-sys filesystem compressed anyway?
In many cases, there is a firmware binary file in many different versions for the same hardware; but even hardware comes in different versions or revisions, and they may require different firmware binaries.
Each kernel-firmware package has a number of provides for its firmware binaries, e.g.
- firmware(RTL8192E/main.img)
- firmware(rt3090.bin)
- firmware(rtl_nic/rtl8153a-4.fw)
They have supplements for the hardware IDs the firmware supports, e.g.
- modalias(pci:v000010ECd00002502svsdbcsci*)
- modalias(pci:v000010ECd00008168svsdbcsci*)
- modalias(pci:v000010ECd00008173svsdbcsci*)
Addendum by Takashi:
Each kernel-firmware-* subpackage contains the hardware supplements, which are retrieved from the corresponding kernel modules, so that they can be installed automatically when the hardware is present. Some other firmware packages have also supplements, too (usually specified in the spec manually).
They typically do not have any meaningful requires.
There is a "bracket" package kernel-firmware-all that pulls in most (almost all) of the other kernel-firmware-* packages.
Do not confuse this package with the legacy kernel-firmware package that is the one before the package split, containing all the firmware binary files in uncompressed format.
Notice that besides kernel-firmware packages, there are also other firmware packages (try zypper search firmware
), e.g.
- adaptec-firmware
- alsa-firmware
- arm-trusted-firmware
- arm-trusted-firmware-a80x0_mcbin
- arm-trusted-firmware-imx8mm
- ...
- atmel-firmware
- b43legacy-firmware
- bcm20702a1-firmware
- bcm43xx-firmware
- bladeRF-fpga-firmware
- bladeRF-fx3-firmware
- bluez-firmware
- gnome-firmware
- raspberrypi-firmware
- raspberrypi-firmware-dt
- raspberrypi-firmware-extra
- rtl8761b-firmware
- sof-firmware
- ...
- ...
To name just a few. None of those gets installed by default, though.
Typically, it's the kernel driver (module) that loads the firmware from those files and uses it. Check the journal (dmesg
or sudo journalctl
).
Addendum by Takashi:
The load of a firmware isn't always shown in the kernel log.
It's visible only when the debugging is enabled on the kernel firmware loader, e.g. passing the
firmware_class.dyndbg=+p
boot option.
Virtual machines (QEMU / LibVirt, VirtualBox, VMWare) do not need any kernel-firmware packages: The virtualization layer takes care of that.
Addendum by Takashi:
Usually no need of firmware for a VM. Due to that reason, kernel-default-base, which is a reduced version of the kernel-default package for VM and co, doesn't have
recommends
of kernel-firmware unlike the standard kernel-default package.Hence, for example, SUSE Micro doesn't install firmware files as default, and it caused problems when you install it on bare metal as a side effect.
Currently, we install all of those kernel-firmware packages; but that is mostly for historic reasons. They used to be all in one single huge kernel-firmware package which, at the time, was the largest package by far that you could install.
Then we asked the maintainer of that package, Takashi Iwai [email protected], if it was possible to split that huge package into smaller ones, and to compress the binary files, and he agreed and did all the (considerable) work. But so far, there has not been a good concept how and when to install only those of the smaller kernel-firmware packages that are actually needed.
Use the result of hardware probing during installation and identify what hardware is present and install only the kernel-firmware package for that hardware.
This really minimizes the number of firmware packages to install at the risk of not having enough of them when the hardware changes ever so slightly (see section Hardware Replacement below).
If this approach is chosen, there should also be an easy way for the user to trigger this again at some later time: Do the hardware probing again, install the missing kernel-firmware packages and ask the user if those that are now not needed anymore should be deinstalled.
USB hardware, for example, cannot be detected that way; it might not be plugged in, or not switched on. But admittedly, that type of hardware does not frequently need firmware binaries.
To verify with Takashi
When a piece of hardware dies, it is typically easy to replace; either individually like a a graphics card, a RAID controller, or a network card, or, more commonly, the whole mainboard with the onboard components.
But that will most often mean replacing it with hardware from a different vendor, or at least with a different hardware revision. And that means that the previously installed kernel firmware package may no longer be the right one for that hardware.
The same is true, of coure, if a new piece of hardware is added to the system, or if one is upgraded to a newer, better one (a new graphics card, for example): The matching kernel-firmware might not be installed yet.
So, if the installation only installs the bare minimals of kernel-firmware packages, just the ones that were needed at the time of installation, we need to be able to add more kernel-firmware packages whenever needed. And firstly, of course, the system must still be able to boot and to allow user interaction (display output, accept input) and to install those packages (i.e. access the network and storage).
To install those additional firmware packages, all the hardware that is needed in that process needs to work; and that means having the firmware for that hardware available: Fetching kernel-firmware packages from a remote repository means a working network connection. Unpacking the RPMs to /lib/firmware
means a working storage controller and working disks. Issuing the commands to start it means a working keyboard, probably also a working mouse or touchpad, and a working video card. And to even get that far after replacing or adding hardware means booting, which again means a working storage controller and working disks.
That does not leave that much hardware that is not needed during that process.
-
Booting:
- Mainboard
- CPU
- Storage controllers
- Disks (including SSDs)
-
User Interaction:
- Graphics card
- Display
- Input devices (keyboard, mouse, touchpad)
- Alternatively: Serial console
-
Connectivity:
- Netword cards
During system installation, all the hardware that is involved in the installation needs to be working; see section Essential Hardware above. Not all that hardware needs to work in the best possible mode of operation, though; to some extent, degraded modes are acceptable.
etc/config in the installation-images GitHub source repo adds those firmare packages to the inst-sys for the x86_64 (PC) architecture:
- kernel-firmware
- adaptec-firmware
- ipw-firmware
- iwl4965-ucode
- iwl5000-ucode
- atmel-firmware
- ralink-firmware
i.e. beyond the legacy kernel-firmware package (containing uncompressed firmware files) also the firmware for very common Adaptec RAID controllers and for a number of WiFi adapters.
(Checked on a Leap 15.5 ISO)
This is much less than expected; just 179.3 MB in 1126 (uncompressed!) files, far from the complete legacy kernel-firmware package's 874.2 MB. This appears to be a hand-curated list of firmware binaries that are actually needed during installation.
To be checked with Steffen
@tiwai, @wfeldt: FYI; still heavily WIP. Comments welcome.
This is a temporary location. Mid-term, this will become part of a GitHub repo like agama, and this will become an alternate location. But it's much more convenient to edit here.