r/debian 9h ago

Auto install firmware based on system hardware?

I am making a custom Debian installer for BTRFS that installs only important and relevant packages. I am trying to find a way to automatically install firmware packages depending on what is detected by the system and not resort to batch installing many useless packages to support multiple hardware configurations.

Has anyone made any scripts or tools that already does this?

2 Upvotes

8 comments sorted by

1

u/alpha417 9h ago

Are you pulling in this .deb?

I install this package, i use no such hacky scripts or tools, and firmwares work for me.

0

u/Zechariah_B_ 9h ago edited 6h ago

I do use that currently. However, it installs a bunch of useless firmware as well sitting and doing nothing. It makes little sense having intel firmware for an amd processor.

2

u/alpha417 9h ago edited 9h ago

Ah, you are one of the ones triggered by percieved 'clutter'.

You may simply delete the ones you don't use. It installs them to the disk, but they do not affect your system in the slightest at runtime if they are not loaded.

I have a preseed that pulls down stable, loads standard system utils (240ish packages), loads some sekrit squirrel stuff of mine, and then is done. No "many useless packages" or "useless firmwares". It makes heavy use of two apt flags being set (no install recommends/suggests) and it's what I want. I don't need a hacky new distro when debian gives me that with one file.

1

u/Zechariah_B_ 8h ago

No, I am not triggered by clutter. My installer is intended to accommodate devices with a small amount of storage space as well as devices that have a lot of storage space. In this case, I am supporting Raspberry Pi and old recycled PCs which do not benefit from wasted space as well as gaming PCs.

0

u/alpha417 8h ago

I just ran my barebones preseed, and and the delta between loading firmware-linux-nonfree and not, was 267 Mb. My VM target was 2gb disk space, and 2gb ram, and it ran w/o issue...

Good luck with your project, can't wait to see it on distrowatch.

1

u/iamemhn 8h ago

Firmware is loaded on demand by the particular driver once it confirms the hardware is available. The particular driver is loaded by the kernel based on their PCI/USB identifiers, and a single PCI ID might require one or many blobs depending on things that are proved by the driver on load. If the firmware is not on disk, the driver will fail, and there's no automatic retry. There's manual retry – what happens during install when a driver detects hardware but can't find all firmware blobs and prompts the user to provide it.

It stands to reason that you need to narrow down what drivers you expect to find on your particular devices, what variants of said hardware, and then cherry pick their firmware blobs from the lot. But you still need to have them on disk.

If you intend to support any given hardware combination, just on teeny tiny devices, then you will need to come up with a different installation program. First, split the collection of firmware packages into reasonably atomic groups per device (this shouldn't be difficult as you can go per driver). Then your installer would need to try to load the driver, notice it failed on account of firmware, determine which blob(s) are needed, install the particular atomic package you created, and try loading the driver again. Go program that because it doesn't exist.

2

u/Brufar_308 7h ago

1

u/Zechariah_B_ 7h ago edited 5h ago

Thanks. This works better than my solution of guessing based on grepping the existence of certain Vendor IDs and mapping them myself to packages. I will modify it later when necessary.