summaryrefslogtreecommitdiff
path: root/content/bsd/thinkpad/freebsd-configuring-nvidia-and-xorg-on-thinkpad-x1-extreme-g2.md
blob: e61fca60ab68d4870ca80e11455f0d1c56a3bec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
+++
title = "FreeBSD: configuring Nvidia and Xorg"
author = ["Michał Sapka"]
date = 2023-03-16T23:02:00+01:00
categories = ["bsd"]
draft = false
weight = 3006
primary_menu = "bsd-thinkpad"
abstract = "A tutorial on making Nvidia work"
[menu]
  [menu.bsd-thinkpad]
    weight = 3006
    identifier = "freebsd-configuring-nvidia-and-xorg"
    name = "Setting up Nvidia"
+++

First, the bad news: I could not make FreeBSD work with Hybrid Graphics, so I use only the discrete one.
To ensure this, open BIOS and:

1.  Configuration
2.  Display
3.  Graphics Device
4.  select \`Discrete Graphics\`

Then, log in as root and install the drivers:

```shell
pkg install nvidia-driver nvidia-xconfig
```

The next step is to enable the drivers.

```shell
sysrc kld_list+=nvidia
sysrc kld_list+=nvidia-modeset
```

Some people advise adding Linux (`sysrc kld_list+=linux`) to kld_list, but I got my GPU working without that.

After that, either load the drivers manually or give the computer an old, good reboot.

Login as root again and use the NVIDIA configurator to get Xorg configured.

```shell
nvidia-xconfig
```

Then try starting your desktop environment, windows manager, or startx.
You may be done, but I got an error about `Screen not found`.
Tell Xorg where the NVIDIA GPU is if you have the same problem.
Try probing the system for GPUs

```shell
pciconf -l | grep vga
```

You will see one on more elements on the list. The critical part is in the first column, for example:

```shell
vgapci0@pci0:1:0:0
```

Our GPU is available under BUS 1:0:0 (we skip the first 0). You may need to try different elements from the list.

> For PCI/AGP cards, the bus−id string has the form PCI:bus:device:function (e.g., “PCI:1:0:0” might be appropriate for an AGP card).
>
> [Xorg documentation](https://www.x.org/releases/X11R7.7/doc/man/man5/xorg.conf.5.xhtml#heading10X)

Open `/etc/X11/xorg.conf`, look for `Section "Device"` and add:

```shell
BusID      "PCI:1:0:0"
```

In my case, everything worked fine after that.

Notes:

I learned the BUS trick from [Nude Systems](https://nudesystems.com/how-to-fix-no-screen-found-xorg-error-on-freebsd/).