Friday, June 12, 2026

Gentoo and nvidia: open /dev/dri/card0: No such file or directory

Gentoo upgrade broke Xorg? It's probably your NVIDIA module.

After a Gentoo system upgrade that includes a new kernel, Xorg can fail to start with a cryptic error: "open /dev/dri/card0: No such file or directory". The display manager dies, XFCE never loads, and you're left staring at a TTY.

The cause is simple. The upgrade installed new kernel sources, but the /usr/src/linux symlink was left pointing at the old ones — or pointing nowhere useful. When nvidia-drivers tries to rebuild its kernel module against the new kernel, it can't find the sources and silently fails. No module, no /dev/dri/card0, no Xorg.

To fix it, first check which kernel you're running and which sources are available:
uname -r eselect kernel list
Then point the symlink at the matching sources: eselect kernel set 1
Finally, rebuild the NVIDIA kernel module: emerge @module-rebuild
Restart your display manager and everything should be back to normal. The lesson: after any Gentoo kernel upgrade, always verify your /usr/src/linux symlink and run emerge @module-rebuild before rebooting.