1. Introduction

Kernel parameters are a way to influence the behavior of a Linux machine during boot. In particular, we can modify many aspects of the system:

The last option is directly linked with the Linux graphics subsystem.

In this tutorial, we’ll explore the low-level kernel graphics subsystem and the i915.modeset command-line parameter. First, we briefly talk about video modes. After that, we discuss ways the kernel influences the setting of these modes. Finally, we go over ways to set the graphics driver with a specific example of Intel Graphics hardware.

We tested the code in this tutorial on Debian 12 (Bookworm) with GNU Bash 5.2.15. It should work in most POSIX-compliant environments unless otherwise specified.

2. Video Modes

Computer systems with graphical display controllers can change their settings by switching so-called modes:

  • screen resolution (800×600, 1024×768, and similar)
  • color depth (1-32b)
  • refresh rate (60Hz, 120Hz, 144Hz, 240Hz, and above)

This usually happens via the VESA Basic Input/Output System (BIOS) or Unified Extensible Firmware Interface (UEFI) Graphics extensions.

Further, the display mode can be set by both the kernel and userspace processes.

Since we require privileges either way, such settings are outsourced to the low-level display server. Critically, all of these changes are dependent on video hardware:

Even through drivers, in the end, the kernel is responsible for the mode change.

3. Kernel Mode Setting (KMS) and Direct Rendering Manager (DRM)

The Direct Rendering Manager (DRM) is a Linux component that manages access to graphics hardware. It’s at the kernel level and directly provides support for the graphics devices to any applications that need it, even simultaneously.

On the other hand, the Kernel Mode Setting (KMS) is a part of the DRM system that sets the video mode in kernel space instead of userspace. Further, KMS configures and initializes the graphics hardware on boot and dynamically. This flexibility also enables proper error handling and output.

To ensure we use KMS, we should disable kernel options such as vgavideo, and other framebuffer drivers such as ubesafb.

How KMS works depends on several factors:

Usually, KMS executes at or right after the initramfs boot stage. Either way, we can set the relevant video driver module according to the graphics controller:

  • AMD: amdgpu
  • Radeon: radeon
  • Intel Graphics: i915
  • nVidia: nvidia, nvidia_modeset, nvidia_uvm, nvidia_drm

Also available are open-source drivers such as nouveau and nvidia-open, as well as specialized hardware like Matrox (mgag200).

Moreover, virtualized graphics controllers such as those for QEMU or VirtualBox have special settings that depend on the virtualization library and current virtual device settings.

All of these drivers can be set for the system in different ways.

4. Set Graphics Driver

The specific driver setting can be set via the initramfs configuration file or directly as a kernel parameter. Sometimes, we can even use the Xorg server.

Let’s look at these scenarios by using the i915 driver.

4.1. Module Kernel Configuration

To use direct kernel modifications for the graphics settings, we can use the /etc/modprobe.d/ directory.

First, we create a .conf file for our driver:

$ cat /etc/modprobe.d/i915.conf
options i915 enable_guc=2 modeset=1

In this case, we just enable the Graphics micro (μ) Controller (GuC) with specific settings according to the exact Intel hardware. In addition, we enable kernel mode setting via i915. Should we use modeset=0 or nomodeset, we instead opt for Xorg handling.

After creating the i915.conf file, we use update-initramfs to regenerate the boot image:

$ update-initramfs -u

Moreover, we can include the -k all option to apply the change to all kernels, not only [-u]pdate the current one.

At this point, after a reboot, the system should use the new settings.

4.2. Kernel Parameters

One way to switch drivers without regenerating initramfs is a command-line kernel boot parameters:

i915.modeset=1 i915.enable_guc=1

To add these, we can we can use the bootloader configuration:

  • /etc/default/grub, in GRUB_CMDLINE_LINUX
  • /etc/grub.conf, on the kernel line

In this case, we use GRUB. As usual, to confirm our changes, we can check the contents of /proc/cmdline from the /proc pseudo-filesystem.

4.3. Xorg

Finally, we can go a level above and set the drivers just before we actually need them.

In particular, we create an X11 configuration file in /usr/share/X11/xorg.conf.d/ with the appropriate Section for a Device:

$ cat /usr/share/X11/xorg.conf.d/666-intel.conf
Section "Device"
  Identifier  "Intel Graphics"
  Driver      "intel"
  Option      "AccelMethod"  "uxa"

Here, the Intel driver is selected and configured, so we should ensure any others are not in conflict with it.

Using any of the first two options here, we can get better graphics during boot. On the other hand, the last method ensures we have access and control over the relevant hardware just before we require it. Either way, we can set modes manually as well.

5. Summary

In this article, we talked about graphics settings at the kernel level by using a specific driver as an example.

In conclusion, although graphics hardware is often detected and configured automatically, knowing how to change these settings can be invaluable, especially when many graphics controllers are involved.

Comments are closed on this article!