# FreeBSD won't start using the Nvidia Geforce RTX 2080 ti as primary card



## ziomario (Apr 7, 2022)

Hello.

I'm trying to passthru my Intel graphic card on a Windows 10 or Linux bhyve VM instead of the nvidia card and for this reason I'm trying to use the nvidia card and driver as primary on FreeBSD. My PC has two graphic cards :

1)


```
vgapci0@pci0:2:0:0:     class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1e04 subvendor=0x19d
a subdevice=0x2503
vendor     = 'NVIDIA Corporation'
device     = 'TU102 [GeForce RTX 2080 Ti]'
class      = display
subclass   = VGA
```

2)


```
vgapci1@pci0:0:2:0:     class=0x030000 rev=0x02 hdr=0x00 vendor=0x8086 device=0x3e98 subvendor=0x145
8 subdevice=0xd000
vendor     = 'Intel Corporation'
device     = 'CoffeeLake-S GT2 [UHD Graphics 630]'
class      = display
subclass   = VGA
```

I tried to start my PC selecting the nvidia card as primary card from the BIOS and I've configured the xorg.conf file giving the proper bus id value to both the cards :


```
Identifier "Card0"
       Driver      "nvidia"
       BusID       "PCI:2:0:0"
```

and the intel as secondary :


```
Identifier  "Card1"
        Driver      "intel"
        BusID       "PCI:0:2:0"
```

I've also tried to cut the sections of the xorg.conf that were referring to the Intel driver and BusID,but has not solved the problem.

In addition I've installed the nvidia driver from ports with the command : pkg install nvidia-driver,I've loaded the nvidia.ko module file from the /boot/loader.conf , I have removed the intel and the drm drivers used by the Intel graphic card,called :


```
xf86-video-intel
drm-fbsd13-kmod
drm-kmod
gpu-firmware-kmod
```

unfortunately my PC wont boot from the nvidia card. Mouse and keyboard freezes just before the desktop manager (xfce and kde5) starts. What's missing / what's wrong ?


----------



## mer (Apr 7, 2022)

I think drm-kmod is needed by nvidia.ko and nvidia-modeset.ko;  both should be loaded.  I think nvidia-modeset has a dependency on nividia so you can just kldload nvidia-modeset and it should load both.  I load both in rc.conf, kld_list variable.

drm-kmod is not just for the intel drivers, it gives the interface to the kernel pieces for the nvidia.


----------



## jmos (Apr 8, 2022)

ziomario said:


> In addition I've installed the nvidia driver from ports with the command : pkg install nvidia-driver,I've loaded the nvidia.ko module file from the /boot/loader.conf


Won't work. Instead you'll need to add "nvidia-modeset" to your kld_list in /etc/rc.conf.


----------



## Profighost (Apr 8, 2022)

Yepp! I observed the exact same problem and figured out the same solution with my RTX 3050:

Loading the nvidia kernel modules while booting will hang up the system terribly.
You'll need to* load the modules after the system is up*: manually, per script or via rc.conf

*DON'T load the nvidia kernel modules in /boot/loader.conf*
Your *system will not even come up as far to provide a shell*. So you'd need to boot externally to correct that entries.
*Beware of using nvidia-xconfig!*
1. You need to copy the config file(s) from /etc/X11 to /usr/local/etc/X11/xorg.conf - _IF_ you want/need those config files.
Just creating a driver-nvidia.conf similar to the examples in the handbook works fine for me.
2. nvdida-xconfig will add the entries into /boot/loader.conf - DON'T let it be!

Instead add

```
kld_list=nvidia
kld_list=nvidia-modeset
```
into /etc/rc.conf
This will work.

I'm neither sure if both are needed nor which one. I did not found any satisfactionary explanation to that, so I did as on my old machine and added both - works.

As not proven - not even tested - I suspect a conflict within PCIe since my new system is installed on a ZFS-mirror of two M.2 nvme.


----------



## mer (Apr 8, 2022)

Profighost is correct about "don't put them in loader.conf" and don't use nvidia-xconfig to generate one.

Add to the kld_list line in /etc/rc.conf, it should look something like this (you don't really need the full path):

kld_list="/boot/modules/nvidia-modeset.ko /boot/modules/nvidia.ko"

A lot of the autodetection for X works very nicely, now so all you really need is  to create a couple of stub confs:

/usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf 
`Section "Device"
        Identifier "NVIDIA Card"
        VendorName "NVIDIA Corporation"
        Driver "nvidia"
        BusID       "PCI:2:0:0"
EndSection`

You could also create another one for the Intel driver.

When testing things with X I prefer booting to a console, logging in and typing startx.  Makes it easier to test and recover.  Once you like the way that it works, reenable your graphical login.

I don't know if it's been fixed, but using Nvidia as the primary display used to have issues switching virtual consoles after starting X.  Basically green blobs or a black screen.  The way to fix it is add the following line
to /boot/loader.conf (reboot for it to take effect):
hw.vga.textmode="1"


----------



## SirDice (Apr 8, 2022)

mer said:


> I think drm-kmod is needed by nvidia.ko and nvidia-modeset.ko;


Nope.


mer said:


> drm-kmod is not just for the intel drivers, it gives the interface to the kernel pieces for the nvidia.


No, graphics/drm-kmod provides drivers for Intel and AMD video cards. The Nvidia driver doesn't use any of it.


----------



## SirDice (Apr 8, 2022)

Profighost said:


> Instead add
> 
> ```
> kld_list=nvidia
> ...


Accidentally. The second `kld_list` overules the first and happens to be the correct one. Remember rc.conf is basically a shell script, variables can only be defined once.


```
#!/bin/sh

mylist="foo"
mylist="bar"

echo $mylist
```

If you want to put multiple values in `kld_list` you have to define it like this: `kld_list="module1 module2 module3"`. This can be easily done by using sysrc(8): `sysrc kld_list+="nvidia-modeset"`.


----------



## mer (Apr 8, 2022)

SirDice Thanks for the correction (that's why I said "I think", yes hedging my bets)


----------



## Profighost (Apr 8, 2022)

Thanks for clearing this up.


----------



## Astralnut (Apr 16, 2022)

I have a 2080 rtx but no built in default video card. All I did was install the base then run desktop-installer and all works beautifully now.


----------

