Xorg and video drivers

Last update: 11.04.2021

In this tutorial, we will install and set up Xorg and the appropriate graphics drivers.


We add our user to the "video" group to allow access to the DRI:

root #: pw groupmod video -m $USERNAME

Then we install the packages xorg and xscreensaver:

root #: pkg install xorg xscreensaver

FreeBSD as a guest on the Virtualbox

If we want to use FreeBSD under VirtualBox, we need the package virtualbox-ose-additions so that we can adjust the resolution automatically.

root #: pkg install virtualbox-ose-additions

Then we enter the following in /etc/rc.conf.

root #: nano /etc/rc.conf =>

vboxguest_enable = "YES"
vboxservice_enable = "YES"
vboxservice_flags = "- disable-timesync"

Video DRM Drivers (Intel, AMD, ATI)

Starting with FreeBSD 11.2, we can use the package drm-fbsd11.2-kmod or for FreeBSD 12 drm-fbsd12.0-kmod can be used:

#FreeBSD 11.2
root #: pkg install drm-fbsd11.2-kmod

#FreeBSD 12
root #: pkg install drm-fbsd12.0-kmod

For amdgpu: sysrc kld_list + = "amdgpu"
For Intel: sysrc kld_list + = "/boot/modules/i915kms.ko"
For radeonkms: sysrc kld_list + = "/boot/modules/radeonkms.ko"

Old drivers

If the new DRM drivers cause problems, we can also use the old drivers.


root #: pkg install xf86-video-intel
root #: sysrc kld_list + = "i915kms"

Radeon Graphic

root #: sysrc kld_list + = "radeonkms"

Video acceleration for Intel graphics cards

For Intel graphics cards, there is a VA-API driver (Video Acceleration API) for video acceleration. We installed the package libva-intel-driver with this command:

root #: pkg install libva-intel-driver

Then we test that it works: and most importantly, we also test the suspend / resume.

For Intel Sandybridge card (or better) users, enabling SNA mode may be beneficial (we check this by measuring the difference with gtkperf, for example).

To activate this mode, an example configuration:

root #: nano /usr/local/etc/X11/xorg.conf.d/20-video.conf =>

"Device" section
   Identifier "Intel Graphics"
   Driver "modesetting"
   "AccelMethod" option "sna"

X11 video driver for Nvidia

For Nvidia drivers there are several drivers depending on the generation of the graphics card (nvidia-driver-304, nvidia-driver-340, nvidia-driver-390, nvidia-driver).

So that we know which GPU is supported by which version, we simply look at the nvidia website.

For a current GPU, we install the nvidia-driver package as follows:

root #: pkg install nvidia-driver

root #: echo 'nvidia_load = "YES"' >> /boot/loader.conf

root #: mkdir -p /usr/local/etc/X11/xorg.conf.d/

root #: nano /usr/local/etc/X11/xorg.conf.d/20-video.conf =>

"Device" section
   Identifier "NVIDIA Card"
   VendorName "NVIDIA Corporation"
   Driver "nvidia"

If there is more than one graphics card in our notebook, the BusID entry can be used to select the desired card. We can get a list of the BusIDs of the graphics cards with pciconf -lv | grep -B3 display.

root #: nano /usr/local/etc/X11/xorg.conf.d/20-video.conf =>

"Device" section
   Identifier "NVIDIA Card"
   VendorName "NVIDIA Corporation"
   Driver "nvidia"
   BusID "PCI: 1: 0: 0"

System Console Frame Buffer (SCFB)

If an accelerated graphics driver is not available for our FreeBSD system, we can use the scfb driver as an alternative. First we install the package xf86-video-scfb:

root #: pkg install xf86-video-scfb

Then we create the file /usr/local/etc/X11/xorg.conf.d/driver-scfb.conf with the following content:

root #: nano /usr/local/etc/X11/xorg.conf.d/driver-scfb.conf =>

"Device" section
   Identifier "Card0"
   Driver "scfb"

dbus and HAL (for Gnome / KDE)

Using HAL is obsolete, as tools increasingly should use devd.

Xorg is compiled with the support of HAL (which is only used to enable the automatic installation of USB devices under Gnome / KDE environments). We configure the automatic start of these:

root #: sysrc dbus_enable = YES
root #: sysrc hald_enable = YES

And we start these services:

root #: service dbus start
root #: service soon start

By default, FreeBSD does not load procfs or fdesc. But for some applications (like HAL), these are required. We edit the file /etc/fstab and add these two lines:

root#: nano /etc/fstab => 

proc    /proc        procfs     rw,late        0    0
fdesc   /dev/fd      fdescfs    rw,late        0    0

root#: mount /proc
root#: mount /dev/fd/


Regarding software that Polkit uses (e.g. xfce), we can specify as follows that the user can shut down the computer and put the user in the "operator" group into hibernation.

root #: nano /usr/local/etc/polkit-1/rules.d/51.shutdown.rules =>

polkit.addRule (function (action, subject) {
    if ((action.id == "org.freedesktop.consolekit.system.restart" || action.id == "org.freedesktop.consolekit.system.stop") && subject.isInGroup ("operator")) {
    return polkit.Result.YES;

root #: nano /usr/local/etc/polkit-1/rules.d/52.resume.rules =>

polkit.addRule (function (action, subject) {
    if (action.id == "org.freedesktop.consolekit.system.suspend" && subject.isInGroup ("operator")) {
    return polkit.Result.YES;

root #: chown -R polkitd /usr/local/etc/polkit-1/

Then we will correct a missing permission problem regarding the actions. We should notice the following errors in the /var/log/messages:

Jul 18 00:21:28 x220 dbus [20382]: [system] Rejected send message, 2 matched rules; type = "method_call", sender = ": 1.19" (uid = 1001 pid = 63293 comm = "") interface = "org.freedesktop.ConsoleKit.Manager" member = "CanSuspend" error name = "(unset)" requested_reply = "0" destination = ": 1.1" (uid = 0 pid = 44489 comm = "")

Jul 18 00:21:28 x220 dbus [20382]: [system] Rejected send message, 2 matched rules; type = "method_call", sender = ": 1.19" (uid = 1001 pid = 63293 comm = "") interface = "org.freedesktop.ConsoleKit.Manager" member = "CanHibernate" error name = "(unset)" requested_reply = "0" destination = ": 1.1" (uid = 0 pid = 44489 comm = "")

To solve this problem (and unlock the “Standby” and “Hibernate” actions) from, e.g. B, to fix XFCE we have to edit the file /usr/local/etc/dbus-1/system.d/ConsoleKit.conf, and add these 6 lines after the last deny line:

root #: nano /usr/local/etc/dbus-1/system.d/ConsoleKit.conf =>

<deny send_destination = "org.freedesktop.ConsoleKit"
     send_interface = "org.freedesktop.DBus.Properties" />
<allow send_destination = "org.freedesktop.ConsoleKit"
      send_interface = "org.freedesktop.ConsoleKit.Manager"
      send_member = "CanSuspend" />
<allow send_destination = "org.freedesktop.ConsoleKit"
      send_interface = "org.freedesktop.ConsoleKit.Manager"
      send_member = "CanHibernate" />
<allow send_destination = "org.freedesktop.ConsoleKit"
      send_interface = "org.freedesktop.ConsoleKit.Manager"
      send_member = "Restart" />


We installed the following pretty fonts:

root #: pkg install dejavu urwfonts bitstream-vera webfonts terminus-font hack-font

We then check what is taken into account in Xorg by this command:

root #: fc-list


As of FreeBSD 12.1, udev has been used to automatically configure input devices.

First, we install the following packages: libinput and xf86-input-libinput:

root #: pkg install libinput xf86-input-libinput

We will now create the following configuration file:

root #: nano /usr/local/etc/X11/xorg.conf.d/99-myinput.conf =>

"InputClass" section
   Identifier "libinput keyboard catchall"
   MatchIsKeyboard "on"
   MatchDevicePath "/dev/input/event*"
   Driver "libinput"
   Option "XkbRules" "evdev"

"InputClass" section
   Identifier "libinput touchpad catchall"
   MatchIsTouchpad "on"
   MatchDevicePath "/dev/input/event*"
   Driver "libinput"
   "MiddleEmulation" option "on"
   Option "DisableWhileTyping" "on"

In the /etc/sysctl.conf we enter the following:

root #: nano /etc/sysctl.conf =>

kern.evdev.rcpt_mask = 12

Further setting options can be found here.


If XOrg was created with devd, we have to use the following settings.

root #: echo 'hw.psm.synaptics_support = "1"' >> /boot/loader.conf

sysrc moused_enable = YES

root #: service moused start

For a Trackpoint or an Elantec, we have to replace the word “synaptics” with your pointer type.

Under Xorg, the xset mouse 5 1 command improves acceleration. We just add this line to our ~/.xinitrc.

root #: nano ~/.xinit =>

xset mouse 5 1

We would like to use a “MacBook”-like scrolling with two fingers. For this we enter the following in /etc/sysctl.conf:

root #: nano /etc/sysctl.conf =>

hw.psm.synaptics.min_pressure = 45
hw.psm.synaptics.max_pressure = 220
hw.psm.synaptics.max_width = 10

hw.psm.synaptics.vscroll_hor_area = 1300
hw.psm.synaptics.vscroll_ver_area = -600
hw.psm.synaptics.vscroll_min_delta = 50
hw.psm.synaptics.vscroll_div_min = 100
hw.psm.synaptics.vscroll_div_max = 150

hw.psm.synaptics.weight_current = 3
hw.psm.synaptics.weight_previous = 6
hw.psm.synaptics.weight_previous_na = 20
hw.psm.synaptics.weight_len_squared = 2000

hw.psm.synaptics.div_min = 9
hw.psm.synaptics.div_max = 17
hw.psm.synaptics.div_max_na = 30
hw.psm.synaptics.div_len = 100

hw.psm.synaptics.margin_top = 200
hw.psm.synaptics.margin_right = 200
hw.psm.synaptics.margin_bottom = 200
hw.psm.synaptics.margin_left = 200

hw.psm.synaptics.window_min = 4
hw.psm.synaptics.window_max = 10
hw.psm.synaptics.multiplicator = 10000

hw.psm.tap_timeout = 0
hw.psm.synaptics.tap_max_delta: 80
hw.psm.synaptics.tap_min_queue: 2
hw.psm.synaptics.taphold_timeout: 125000

To define the keyboard type, we create the configuration file /usr/local/etc/X11/xorg.conf.d/10-keyboard.conf, which is filled with the following content:

root #: nano /usr/local/etc/X11/xorg.conf.d/10-keyboard.conf =>

"InputClass" section
   Identifier "Keyboard Defauls"
   Driver "keyboard"
   MatchIsKeyboard "on"
   Option "XkbLayout" "de"
Your E-Mail address will be encrypted before saving the comment. It will only be used to display a gravatar. By submitting your data, you agree that all entered data may be saved and displayed as a comment.