Doing this would probably be much easier as a script that runs on your first boot instead of from within the installer.
That said, a quick test by manually doing "Load installer components from installation media" and then selecting "sound-modules-5.10-8-amd64-di: sound support" (in Debian 11, but likely there on Debian 10 too) correctly inserts the necessary kernel modules. Installing alsa-utils (in-target) works out of the box on VirtualBox. Running aplay
works too, provided that you un-mute the card using amixer
first.
The preseed line required for Debian 11 would look like:
d-i preseed/early_command string anna-install sound-modules
(...there are other ways, this one worked for me)
Then you would also need to make sure that you have alsa-utils on the target. Nothing is needed if you are using a "task" such as Desktop environment, etc. But if it's a bare system, you'd need:
d-i pkgsel/include string alsa-utils
Finally, to make some noise (pun intended):
d-i preseed/late_command string in-target /bin/sh -c \
"amixer set Master 80% unmute; amixer set PCM 80% unmute; aplay /usr/share/sounds/alsa/Noise.wav"
With a working alsa stack, you could easily get a list of hardware audio devices by doing aplay -l
or similar (in-target) and using that information in your setup script later on.
While this could work, I can imagine that it'd be really tricky to get this right with different hardware setups. Some soundcards would need additional switches or outputs to be selected, etc. Moreover, the modprobe
options in the final system could be substantially different from the d-i environment and affect card indexes, etc. Happy hacking!