How can I automate Dracut to automatically add NVIDIA drivers so during boot I have both my monitors working.
My meaning here is:
Every single update to the NVIDIA drivers or kernel after installing and akmods doing its things, reboot etc. I ran dracut for it to add the nvidia modules so during boot, I have my external monitor/monitors enabled and showing the boot process and mainly the Plymouth LUKS prompt for me to unlock my drive. Without it, it will only show it on my laptop’s screen.
I created the files inside /etc/dracut.conf.d and /etc/modprobe.d, but it only works after I run dracut, usually for all kernels at once: doas dracut --verbose --force --printsize --parallel --regenerate-all
Inside the /usr/lib/kernel/install.d/50-dracut.install the dracut command receive values from another file
The problem is the initrd is built because a new kernel is installed.
But only after that all completes does akmods build a new nvidia module.
As you found that means you must run dracut again to include the nvidia module in the initrd.
You could add a systemd override for the akmods.service that will run a script of yours that does the dracut run as an ExecStartPost= action.
And you must wait for all these post upgrade services to complete before rebooting.
I use a script that waits for systemctl list-jobs to report “No jobs running.” before rebooting.
Should I have akmods.service or some that has akmod in the name?
~
.374ns fsh ❯ doas systemctl status akmods.service
Unit akmods.service could not be found.
~
.426ns fsh ❯ systemctl --user status akmods.service
Unit akmods.service could not be found.
When the package akmods is installed that service is automatically installed and enabled.
$ systemctl status akmods | cat
● akmods.service - Builds and install new kmods from akmod packages
Loaded: loaded (/usr/lib/systemd/system/akmods.service; enabled; preset: enabled)
Drop-In: /usr/lib/systemd/system/service.d
└─10-timeout-abort.conf, 50-keep-warm.conf
Active: active (exited) since Sat 2025-01-18 20:39:25 CST; 6 days ago
Invocation: 50019b18a2404b279f2989d316b1c2bc
Process: 1358 ExecStart=/usr/sbin/akmods --from-init (code=exited, status=0/SUCCESS)
Main PID: 1358 (code=exited, status=0/SUCCESS)
Mem peak: 62.5M
CPU: 188ms
Jan 18 20:39:24 eagle.home.domain systemd[1]: Starting akmods.service - Builds and install new kmods from akmod packages...
Jan 18 20:39:25 eagle.home.domain akmods[1358]: Checking kmods exist for 6.12.9-200.fc41.x86_64[ OK ]
Jan 18 20:39:25 eagle.home.domain systemd[1]: Finished akmods.service - Builds and install new kmods from akmod packages.
Note I did not run that as the superuser.
It was last run when I upgraded to the 6.12.9 kernel.
Every kernel upgrade that triggers building new modules means the user must wait for adequate time while the modules are compiled and installed before rebooting, or the modules may not be properly built and installed.
Failure to wait may mean that the user might need to build (or rebuild) the modules manually with the command sudo akmods --force --rebuild. In that case it may become necessary to run dracut manually as well.
Sorry, I copied my dotfiles to a test install and forgot that I wasnt on my main system at the time. Thanks for the answer.
I know about the wait, but at least in the past it was a gamble. Even letting the system update and wait, and I mean wait by keep working on the system and after a half hour, hour restart, was not a guarantee that it would do its thing. Some times it would restart to a only one monitor working; sometimes it would restart to both monitor working, but, at least on my system never dual monitors during the Plymouth LUKS prompt. To have that I needed to manually run dracut after adding a NVIDIA configuration file to the /etc/dracut.conf.d/ folder.
I used to use the force_drivers instead of add_drivers, but after one update/release last year, I don’t recall when, made that if it ran dracut with it Plymouth would break during boot.
As I don’t use RPMFusion for that anymore, I don’t know if those are really fixed. I’m willing to test it again. Will it really work if I uninstall what I have (negativo17) and just reinstall the drive from RPMFusion? I mean the Plymouth LUKS prompt being available on all screens monitors during boot, not just the integrated one like happens with me on my laptop.
I’m thinking nowadays, on the case of NVIDIA drivers (RPMFusion or Negativo17), an offline install using sudo dnf install akmod-nvidia xorg-x11-drv-nvidia-cuda --offline followed by a sudo dnf offline-upgrade reboot would probably be a better approach, would it?