Which service creates /dev/fb0 node?

I want to update the console-setup.service to detect screen resolution using fbset -s and adjust console font size accordingly. For fbset, I need /dev/fb0 to be present, but I don’t know which service I should create a dependency on. How is /dev/fb0 created on startup?

Asked By: Tomasz Garbus


/dev/fb0 is created by the kernel as soon as the first framebuffer display driver has detected and initialized the respective display controller hardware.

If that driver is built into the kernel, it might effectively already be there when userspace processes start running.

If you add a udev rule like:

SUBSYSTEM=="graphics", KERNEL=="fb0", TAG+="systemd"

you should get a *.device unit for it, which you can then use for dependencies.

If you add ENV{SYSTEMD_WANTS}+="your.service" to the udev rule, udev will tell systemd to start your service as soon as this device appears, so you could run fbset as a separate service if it suits your plans.

At least Debian 12 has console-setup.service run After=console-screen.service kbd.service local-fs.target, but console-screen.service does not seem to be defined. So you might define your own console-screen.service that runs your fbset and console font operations, and have udev trigger it with

SUBSYSTEM=="graphics", KERNEL=="fb0", ENV{SYSTEMD_WANTS}+="console-screen.service"

as soon as the device becomes available.

Then the order of operations would be: /dev/fb0 appears -> your custom console-screen.service runs -> console-setup.service runs.

You could then configure the standard console-setup.service to leave the console font alone, and instead set it in your custom console-screen.service.

Answered By: telcoM
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.