This is ridiculous. The documentation has me all over the place. One says use /boot/loader.conf, but any time I load anything nvidia there, I get stuck in a mountroot>. When I attempt to load anything via mountroot>, the system hangs. So apparently using bootloader is wrong.
See, one particularly bad thing about the internet is, that it does not forget. The result is that when you search for guidance about a thing (even more so if said thing has existed for so long) you will come across a great amount of outdated information that has been valid at some point in time, but that moment is long gone.
So lets take it step by step. First thing after installing the correct nvidia-driver(-xxx) package for your particular nvidia hardware is to make sure it gets loaded upon system startup. The now preferred way of doing this is to add
nvidia-modeset to the
kld_list variable in your
/etc/rc.conf file. This method
replaces loading the driver from
/boot/loader.conf, so make sure that there is no
nvidia_load="YES" in that file anymore. When this is done, reboot the machine and check output from
dmesg | grep nvidia
to see if the driver got initialized correctly upon boot.
Next, forget all about running
Xorg -configure
or similar nvidia tools to auto-generate an initial
xorg.conf file, as that stuff is like from the stone ages of X. Modern X servers auto-probe most hardware and can even go without any configuration file at all. Therefore you should start afresh and make sure that there are no leftover configuration files (i.e.
/usr/local/etc/X11/xorg.conf or in
/usr/local/etc/X11/xorg.conf.d) before you continue. Unfortunately one of the few things the X server does not automatically detect is nvidia GPUs. So you have to create a minimal configuration file that tells X to actually make use of the nvidia driver. Create a new file
/usr/local/etc/X11/xorg.conf.d/20-nvidia.conf with the following contents (change Identifier and BoardName as you see fit):
Code:
Section "Device"
Identifier "GTX-nnnn"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce GTX nnnn"
EndSection
With that in place it's time to test whether the bare X server (no fancy DE, no graphical login manager, etc) starts up correctly using the nvidia driver. On your regular (non-root) user account make sure to remove or move aside any
.xinitrc file you might have in your home directory, then fire up
startx
. If everything is alright, a very basic desktop using twm window manager and some xterms should appear. Check
/var/log/Xorg.0.log for any potential problems, in particular any lines starting with (WW) or (EE). In this file you should also see that the nvidia driver is being used. You might want to check whether your input devices (keyboard/mouse) work as expected or if they require additional tweaking (keyboard layout, etc).
Only after everything so far is working you should go about setting up a desktop environment/your window manager of choice. Whether you start that by means of
.xinitrc
or using a graphical login manager like sddm, slim, xdm, etc is a matter of personal preference and taste.