How To Install Drivers On Linux

How To Install Drivers On Linux

Reading time1 min
#Linux#Drivers#OpenSource#KernelModules#DriverInstallation

Mastering Driver Installation on Linux: From Kernel Modules to Manual Configurations

Driver installation on Linux is sometimes a non-trivial exercise, especially when dealing with recent hardware, enterprise-grade components, or edge-case peripherals. Expecting distribution defaults to always “just work” is optimistic at best—particularly with Wi-Fi adapters, GPUs, or custom PCIe devices.

Below: practical workflow for identifying, installing, and tuning drivers in contemporary Linux environments. This covers both mainstream distributions (Ubuntu 22.04 LTS, Fedora 39, Arch 2024.04) and edge scenarios.


Reality: Why Manual Driver Management Still Matters

Automated installers (e.g., Ubuntu’s Additional Drivers, Fedora’s akmods) cover the bulk of commodity hardware. However:

  • Vendor releases frequently lag kernel updates.
  • Niche hardware (specialist audio interfaces, enterprise storage cards) often lacks distribution packages.
  • Kernel regressions can disable previously working drivers between point releases.
  • Tuning for power management, RF, or performance necessitates hands-on module configuration.

Side effect: vendor-provided drivers may blackbox certain facilities, obstructing debug of low-level issues.


Quick Audit: What Hardware + Drivers Are Active?

Skip the guesswork. Start here.

lspci -nnk

Returns, e.g.:

03:00.0 Network controller [0280]: Intel Corporation Wireless 9260 [8086:2526]
	Subsystem: Intel Corporation Device 0010
	Kernel driver in use: iwlwifi
	Kernel modules: iwlwifi

Key lines: device/vendor IDs, active driver, available modules.

Require deeper USB device discovery (e.g. printers, some 4G modems):

lsusb -v | less

Pro tip: always capture both vendor and device IDs (8086:2526)—vital when searching upstream mailing lists, kernel commit logs, or vendor README.md files.


Verifying Module Status and Lifecycle

Module loaded? Test with lsmod:

lsmod | grep iwlwifi

If missing, insert manually:

sudo modprobe iwlwifi

Unload (for troubleshooting, applying config changes, or upgrading):

sudo modprobe -r iwlwifi

Kernel events and errors surface in dmesg. Filtering for relevant lines saves time:

dmesg | grep -i firmware

or

dmesg | tail -40

Typical firmware load error (seen with fresh chipsets):

[3011.012345] iwlwifi 0000:03:00.0: Direct firmware load for iwlwifi-9260-th-b0-jf-b0-46.ucode failed with error -2

Means: firmware binary not present—address next.


Hardware Vendor Packages and Distribution Integration

Case: NVIDIA GPUs on Ubuntu 22.04+.

  • Open-source (nouveau) loads by default but lacks features (NVIDIA Dynamic Boost, CUDA).
  • Proprietary (nvidia-driver-535) provides full stack but sometimes lags the upstream kernel ABI.

Steps (Ubuntu as example):

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-drivers devices
sudo apt install nvidia-driver-535
sudo reboot

Validation:

nvidia-smi

Failure mode: If kernel is newer than Nvidia supports, modprobe: ERROR: could not insert 'nvidia': No such device. Consider DKMS builds or downgrade the kernel.


Building and Installing Drivers From Source

Essential for out-of-tree modules or mainline lag (e.g., Realtek RTL8812AU USB Wi-Fi, Broadcom Wi-Fi, or custom hardware).

  1. Check for existing DKMS packages first (saves time).

  2. Dependencies:

    • Ubuntu/Debian: sudo apt-get install build-essential linux-headers-$(uname -r) dkms git
    • Fedora: sudo dnf install @development-tools kernel-devel dkms git
  3. Clone the source:

git clone https://github.com/aircrack-ng/rtl8812au.git
cd rtl8812au
  1. Build and install:
make
sudo make install

Better: prefer DKMS when the source supports it:

sudo make dkms_install
  1. Insert module:
sudo modprobe 8812au

Gotcha: Some modules only support kernels up to a certain version (e.g. 5.18). Read upstream Issues/PRs for workarounds or forked versions.


Dealing With Firmware Blobs

/var/log/syslog and dmesg filled with firmware errors? Device likely needs additional binary blobs. Distributions often bundle these (linux-firmware, firmware-iwlwifi, firmware-realtek).

Manual installation:
Download the .ucode, .bin, or .fw file from vendor or kernel.org, place into /lib/firmware/${vendor}, and reload the module.

sudo cp iwlwifi-9260-th-b0-jf-b0-46.ucode /lib/firmware/
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi

Note: Always match firmware version to driver; mismatch can silently degrade performance or feature set.


Persistent Tuning via modprobe.d

Optimizing for stability or performance isn’t always plug-and-play. Example: disabling aggressive Wi-Fi power management, which can cause packet loss or latency spikes.

Edit /etc/modprobe.d/iwlwifi.conf:

options iwlwifi power_save=0 swcrypto=1 bt_coex_active=0

Apply without reboot:

sudo modprobe -r iwlwifi && sudo modprobe iwlwifi

Alternative: Tune on-the-fly via sysfs in /sys/module/<module_name>/parameters/, but these reset after reboot.


Advanced: Blacklisting and Conflict Management

When two drivers fight for one device (common with nouveau vs. nvidia, or r8169 vs. r8168):

  1. Add to /etc/modprobe.d/blacklist.conf:
blacklist nouveau
  1. Update initramfs (Debian/Ubuntu):
sudo update-initramfs -u
  1. Reboot.

Side note: Some installer scripts neglect to do step 2, resulting in the old (blacklisted) module still being loaded at boot.


Troubleshooting and Non-obvious Scenarios

  • Stuck in initramfs due to missing storage driver: Retrieve correct module, copy to /lib/modules/$(uname -r)/kernel/drivers/, run depmod, and retry boot.
  • DKMS fails silently: Check /var/lib/dkms/<modulename>/ for build logs.
  • Switching kernels: Out-of-tree modules often need to be rebuilt or reinstalled. Automate with DKMS where possible.
  • Non-PCI devices (e.g., I2C, SPI): Use dmesg, lsmod, and trace device-tree overlays (esp. on ARM SBCs).
  • Kernel boot parameters can matter: e.g., PCIe ASPM, ACPI quirks. Append to GRUB as needed.

Key Reference Commands

TaskCommand
List PCI deviceslspci -nnk
List USB deviceslsusb -v
List moduleslsmod
Insert/remove modulesudo modprobe <modname>, sudo modprobe -r <mod>
View dmesg for errors`dmesg
Identify kernel versionuname -r
Persistent module options/etc/modprobe.d/*.conf
DKMS statusdkms status

Epilogue: The Real Work

Getting Linux to handle unfamiliar or bleeding-edge hardware requires a blend of reconnaissance, methodical driver/module management, and triage of logs/errors.
No universal fix; sometimes “try mainline,” sometimes “pin kernel at an older revision.”
Always document your working solution. A single config line buried in modprobe.d can spare hours on future rebuilds.

For hardware that’s consistently problematic: check LKML, vendor GitHub issues, and distribution bug trackers for patches, workarounds, or alternative modules long before assuming “unsupported.”

No setup is perfect—the best you can do is make your process repeatable.


Known issue: Some distributions (notably, recent Fedora spins) have dropped certain proprietary driver support by default. If packages are missing, correlate with your specific distribution version and consult the respective release notes before troubleshooting endlessly.