Modernizing the console with kmscon




For decades, the Linux virtual console has relied on the kernel fbcon driver, to draw the framebuffer, to manage fonts, and to handle keyboard layout. Starting with Fedora 45, we’re switching to a userspace utility called kmscon. Depending on your usage of virtual console, this may impact your workflow. If you’re not a developer or a system administrator, chances you probably never heard about fbcon or virtual terminal (VT), in this case you’re probably not impacted. You can still read the rest if you’re curious about minimal text interfaces, and maybe you’ll start using it. How to use the virtual…

Read More
5 Likes

I understand that this is about virtual consoles, after the system as finished the boot sequence.

But I don’t fully understand the consequences for “other” console outputs. I wonder, if this new console can also be used during boot time, so that console messages or inputs like the LUKS prompt are easier to read?

Yes, it’s a first step for Fedora 45.
For Fedora 46, the goal would be to also use kmscon for the LUKS password and for the ramdisk rescue console. With that done it will be possible to switch to kernel drm_log [1] driver for early boot messages. (So you can see kernel messages before the userspace is started).

[1] drm/log: Introduce a new boot logger to draw the kmsg on the screen [LWN.net]

2 Likes

the Cascadia font does include nerd font icons on the cascadia-code-nf-fonts subpackage, which is available from the fedora repository

Thank you for the article! I am in the fedora beta and indeed mpv could not access the drm directly with kmscon running. It worked after disabling the kmscon service but after reading that kmscon will be used more I wanted to get it working with kmscon.
$ kmscon-launch-gui mpv worked from the command line directly, but I’m still figuring out how to start it from a user service..

I dont think I want to launch it as root with the --login with eg:

$ sudo systemctl edit kmsconvt@tty1.service
[Service]
ExecStart=kmscon --vt=%I --no-switchvt --login -- /usr/bin/mpv --input-ipc-server=%t/mpv.sock

If you want to keep a tty using fbcon, just in case, you can run
sudo systemctl mask kmsconvt@tty5 && sudo systemctl enable --now getty@tty5

So played around with the systemd services while reading the article :slight_smile:

$ sudo systemctl enable --now getty@tty1
Failed to enable unit: File '/etc/systemd/system/autovt@tty1.service' already exists and is a symlink to /usr/lib/systemd/system/kmsconvt@.service

I think this file was left by this:

$ sudo systemctl enable kmsconvt@tty5
Created symlink '/etc/systemd/system/autovt@tty5.service' → '/usr/lib/systemd/system/kmsconvt@.service'.
Created symlink '/etc/systemd/system/getty.target.wants/kmsconvt@tty5.service' → '/usr/lib/systemd/system/kmsconvt@.service'.
$ sudo systemctl disable kmsconvt@tty5
Removed '/etc/systemd/system/getty.target.wants/kmsconvt@tty5.service'.
$

what should be done with the autovt file? Is it a bug or expected?

The way I read this, and I might be out in left field is Unlike fbcon, which runs in the kernel and lets any userspace program grab the GPU freely, kmscon exclusively controls the GPU via DRM and must explicitly hand it off first.

Normally autovt is kind of a fallback, if no other service is enabled for this tty, systemd will start this service, so that you always have something when switching to this VT.

Did you mask kmsconvt@tty1 like it’s done in the example ?

Regarding your use case, to start mpv in a tty, you probably want to use a minimal wayland compositor like cage instead:

In fact I’ve also done some scripts to start this kind of service, with a terminal:

This allows to start a minimal wayland compositor as an unprivileged user, (either cage, mutter, or kwin), and start a terminal. You can probably adapt the scripts to start mpv instead.

Most of the complexity is about creating a pts and giving that to ptyxis/konsole, but for mpv, you won’t need that.

Thank you for the replies.

I did mask it afterwards, but I manually removed the left over autovt service before I could enable getty.

Thanks for the links also, and its neat to see what is needed for a complete copr package :slight_smile:
I am trying it with cage now, the user service seems to start, but I can’t see the output on the tty, it seems to be a similar problem as with the kmscon-launch-gui, it does work from the command line. To really follow the advice from the cage wiki and your cagefootvt I will also try it with a system service first and go from there.

You can also start cage from kmscon like this:

kmscon-launch-gui cage -- mpv test.mp4

But for your case having a systemd service with cage+mpv looks better.

It’s running smoothly now, getty + cage and mpv was the way to go :slight_smile:
The kmscon-launch-gui script uses printf to release the gpu, I could print to the current $(tty), but this feels like a hack to do from a systemd user service

I assume somewhere that ESC sequence is documented and is the API to control kmscon. So why not use it?

If prompts like offline DNF upgrades and LUKS can be done without systemd spewing all over them and losing the desired output in a mess of systemd messages, this would actually be a great way to avoid using plymouth and rhgb. Not that I see Fedora changing over from those two, but for people who don’t like/use plymouth and rhgb it will help.