Drivers and kernel modules on FreeBSD

freebsd 15 / published / guide #79 / ≈ 4 min read

FreeBSD doesn't have a driver manager — partly by tradition, partly because its driver story is built around kernel modules (kld) that load on demand. This guide is the orientation: how to figure out what hardware you have, how to load the right module, and how to make it stick across reboots.

FreeBSD vocabulary you'll meet:

  • kld — kernel loadable module. Drivers live here.
  • devd — the device daemon; reacts to hot-plug events.
  • drm-kmod — the umbrella package for modern graphics drivers (Intel/AMD).
  • iwlwifi / iwm / urtwn — Wi-Fi chip drivers.

Step 1: see what hardware you have

pciconf -lv            # PCI devices: GPU, network, sound, USB controllers
usbconfig list         # USB devices
sysctl hw.model        # CPU
dmesg | less           # everything the kernel saw at boot

The dmesg at boot is the most informative read in your entire system. It tells you which drivers attached to which devices, and complains about ones it couldn't handle.

Step 2: see which modules are loaded right now

kldstat                # currently loaded modules
kldstat -v             # with verbose info on each

Step 3: load a module by hand

To try a module without rebooting:

sudo kldload nvidia                # load the nvidia driver
sudo kldload if_iwlwifi            # load the modern Intel Wi-Fi driver

If it loads cleanly, run kldstat to confirm. If it errors, dmesg has the reason.

To unload:

sudo kldunload nvidia

Step 4: load a module on every boot

Edit /boot/loader.conf — modules loaded here come up before init:

sudo nano /boot/loader.conf
nvidia_load="YES"             # NVIDIA proprietary driver
if_iwlwifi_load="YES"         # modern Intel Wi-Fi
if_iwm_load="YES"             # older Intel Wi-Fi (3160/7260/8260/8265)
if_rtwn_usb_load="YES"        # Realtek USB Wi-Fi
zfs_load="YES"                # ZFS (default on most installs)

Persistent kernel settings — sysctl values that need to be set early — go in the same file, e.g. vfs.zfs.arc_max="2G".

Reboot, then kldstat should show them all.

Step 5: graphics (the modern way)

For modern Intel and AMD GPUs, install the umbrella package:

sudo pkg install drm-kmod

Then tell the system which one to load:

sudo sysrc kld_list+="i915kms"            # Intel
sudo sysrc kld_list+="amdgpu"             # AMD GCN 1.2+
sudo sysrc kld_list+="radeonkms"          # older AMD (pre-GCN 1.2)

Add your user to the video group so they can use the GPU:

sudo pw groupmod video -m your-username

Log out and back in. Reboot to load the new module.

NVIDIA

sudo pkg install nvidia-driver nvidia-modeset       # the kernel module + utilities
sudo sysrc kld_list+="nvidia-modeset"
echo 'hw.nvidiadrm.modeset=1' | sudo tee -a /boot/loader.conf

Reboot.

Step 6: Wi-Fi

FreeBSD's Wi-Fi support is more limited than Linux's, but the common Intel and Realtek chips work fine.

Identify your card:

pciconf -lv | grep -B 3 -i wireless

Match the driver to the chip (most common):

  • Modern Intel (AX2x0, AX21x, AX41x): if_iwlwifi
  • Older Intel (3160, 7260, 8260, 8265): if_iwm
  • Realtek USB: if_rtwn_usb or if_urtwn
  • Atheros: if_ath (usually loaded automatically)

Load it in /boot/loader.conf (see Step 4), then set up /etc/wpa_supplicant.conf:

sudo nano /etc/wpa_supplicant.conf
network={
    ssid="YourNetwork"
    psk="your-password"
}

And in /etc/rc.conf:

sudo sysrc wlans_iwlwifi0="wlan0"
sudo sysrc ifconfig_wlan0="WPA SYNCDHCP"

(Replace iwlwifi0 with your actual interface — see ifconfig.)

Bring the interface up:

sudo service netif restart

Step 7: Bluetooth

FreeBSD's Bluetooth stack is older and more limited. For most laptops with built-in Bluetooth via USB:

sudo pkg install bluez-firmware
sudo sysrc hcsecd_enable="YES"
sudo service hcsecd start
sudo hccontrol -n ubt0hci read_node_state

Pairing is interactive via hcsecd. Honestly, if Bluetooth is critical for your workflow, FreeBSD is harder than Linux here.

Step 8: sound

FreeBSD's sound stack (OSS) is built into the kernel. Usually it just works:

cat /dev/sndstat                # list audio devices and which is default
sysctl -a | grep snd.default_unit
sudo sysctl hw.snd.default_unit=1     # switch default to device 1

For per-app volume control, install:

sudo pkg install mixer
mixer -S                                # show settings
mixer -a 80                             # set master to 80%

Step 9: printers

sudo pkg install cups gutenprint
sudo sysrc cupsd_enable="YES"
sudo service cupsd start
# add printers via http://localhost:631/

Where to look when something doesn't work

dmesg | tail -50                 # what the kernel just said
kldstat                          # is the module even loaded?
pciconf -lv | less               # does the device show up at all?
sysctl dev.<driver>              # driver-specific tunables

If the kernel saw the device at boot (dmesg lists it) but no driver attached, the FreeBSD handbook chapter on the specific subsystem (Wi-Fi, Sound, Graphics) is where the per-chip notes live. The FreeBSD wiki's Laptop page is also surprisingly good for the "does anyone have this exact laptop working?" question.

The done check

kldstat                                              # right modules loaded?
ifconfig                                             # all NICs up?
cat /dev/sndstat                                     # audio device detected?
glxinfo | grep "OpenGL renderer"                     # GPU acceleration working? (needs mesa-demos)

If kld shows what you expect, networks come up, sound has a default device, and glxinfo reports your real GPU instead of the software rasterizer — you're fully set up.

← back to index