rmmod nouveau .. no, it's not in use!
TL;DR: I learned that even if you don’t have a display server running, chances are that Linux is still using the graphics driver - which makes sense, framebuffers don’t draw themselves on their own. But that’s still annoying if you want to install a graphics driver without having to reboot.
I recently had to install the proprietary drivers for a Nvidia GPU on Linux again, after not having done that for literal years. In theory the process is straightforward as can be:
- Download the appropriate driver installer from the Nvidia-website
- Install all the prerequisite packages - kernel headers, development tools, compilers, ..
- Blacklist the
nouveau
-driver which is typically in use - Reboot the system
- Install the driver through the downloaded installer, be happy
However, in my specific case, I wanted to avoid rebooting. That is because the system in question is located in the server rack under my table, with encrypted hard disks - it’s my homeserver after all.
That would have meant that I would have had to either painfully attach a screen to the computer, or hope that I successfully entered the passphrase for the disks blindly at the right point. I could have used this situation as motivation to set up Dropbear, but I have to admit that I couldn’t be bothered.
But, given that the computer wasn’t running any display server, I figured that
I wouldn’t really need the blacklisting or the rebooting part, because there
was no reason nouveau
should be loaded.
The output of lsmod
told me that I was wrong in my assumption. For whatever
reason nouveau
was loaded. I couldn’t really understand why, but that didn’t
matter, simply running rmmod nouveau
would surely do the trick, right?
rmmod: ERROR: Module nouveau is in use
Apparently not. Which confused me, because I wasn’t able to think of anything that would use the driver. I was connected to the system via SSH, there wasn’t a screen attached to the device. What I completely forgot about was the fact that virtual terminals are, despite not relying on a display server, still graphical output, thus needing a graphics driver - and, in all fairness, I didn’t magically remember the fact, a thread on askubuntu.com pointed me towards the right direction:
echo 0 > /sys/class/vtconsole/vtcon1/bind
On the upside I was now able to rmmod nouveau
, on the downside I was now
without virtual terminals. And, knowing myself, I will forget about that in a
matter of days, which means that if I end up needing a virtual terminal for
debugging purposes in a few months, I will be majorly confused. But that’s an
issue for future me.