Debian and the adventure of the screen resolution
I read somewhere a nice meme about Linux: Do you want an operating system or do you want an adventure? I love it, because it is so true. What you are about to read is my adventure to set a usable screen resolution in a fresh Debian testing installation.
The context is that I have two different Lenovo Thinkpad laptops with 16” screen and nvidia graphic cards. They are both
installed with the latest Debian testing. I use the closed-source nvidia drivers (they seem to work better than the nouveau
module). The desktop manager and environment that I use is lightdm + XFCE4. The monitor native resolution in both machines
is very high: 3840x2160
(or 4K UHD
if you will).
The thing is that both laptops show an identical problem: when freshly installed with the Debian default config, the native resolution is in use. For a 16” screen laptop, this high resolution means that the font is tiny. Therefore, the raw native resolution renders the machine almost unusable.
This is a picture of what you get by running htop
in the console (tty1, the terminal you would get by
hitting CTRL+ALT+F1
) with the default install:
Everything in the system is affected by this:
- the grub menu is unreadable. Thanksfully the right option is selected by default.
- the tty console, with the boot splash by systemd is unreadable as well. There are some colors, so you at least see some systemd stuff happening in ‘green’.
- when lightdm starts, the resolution keeps being very high. Can barely click the login button.
- when XFCE4 starts, it is a pain to navigate the menu and click the right buttons to set a more reasonable resolution.
The adventure begins after installing the system. Each of these four points must be fixed by hand by the user.
XFCE4
Point #4
is the easiest. Navigate with the mouse pointer to the tiny Applications menu, then Settings, then Displays.
This is more or less the same in every other desktop operating system. There are no further actions required to persist this
setting. Thanks you XFCE4.
lightdm
Point #3
, about lightdm, is more tricky to solve. It involves running xrandr
when lightdm sets up the display.
Nobody will tell you this trick. You have to search for it on the internet. Thankfully is a common problem, and a
person who knows what to search for can find good results.
The file /etc/lightdm/lightdm.conf
needs to contain something like this:
[LightDM]
[Seat:*]
# set up correct display resolution
display-setup-script=sh -c -- "xrandr -s 1920x1080"
By the way, depending on your system hardware setup, you may also need an additional call to xrandr here. If you
want to plug in an HDMI monitor, chances are you require something like xrandr --setprovideroutputsource NVIDIA-G0 modesetting && xrandr --auto
to instruct the NVIDIA graphic card to work will with the kernel graphic system.
In my case, one of my laptops require it, so I have:
[LightDM]
[Seat:*]
# don't ask me to type my username
greeter-hide-users=false
# set up correct display resolution, and prepare NVIDIA card for HDMI output
display-setup-script=sh -c "xrandr -s 1920x1080 && xrandr --setprovideroutputsource NVIDIA-G0 modesetting && xrandr --auto"
grub
Point #1
about the grub menu is also not trivial to solve, but also widely known on the internet. Grub allows you to
set arbitrary graphical modes. In Debian systems, adding something like GRUB_GFXMODE=1024x768
to /etc/default/grub
and then
running sudo update-grub
should do the magic.
console
So we get to point #2
about the tty1 console. For months, I’ve been investing my scarce personal time into trying to
solve this annoyance. There are a lot of conflicting information about this on the internet. Plenty of misleading solutions,
essays about framebuffer, kernel modeset, and other stuff I don’t want to read just to get my tty1 in a readable status.
People point in different directions, like using GRUB_GFXPAYLOAD_LINUX=keep
in /etc/default/grub
. Which is a good solution,
but won’t work: my best bet is that the kernel indeed keeps the resolution as told by grub, but the moment systemd loads the nvidia
driver, it enables 4K in the display and the console gets the high resolution.
Actually, for a few weeks, I blamed plymouth. Because the plymouth service is loaded early by
systemd, it could be responsible for setting some of the display settings. It actually contains some (undocummented)
DeviceScale
configuration option that is seemingly aimed to integrate into high resolution scenarios. I played with it to no avail.
Some folks from IRC suggested reconfiguring the console-font
package. Back-then unknown to me. Running
sudo dpkg-reconfigure console-font
would indeed show a menu to select some preferences for the console, including font size.
But apparently, a freshly installed system already uses the biggest possible, so this was a dead end.
Other option I evaluted for a few days was touching the kernel framebuffer setting. I honestly don’t understand this, and all the
solutions pointing to use fbset
didn’t work for me anyways. This is the default framebuffer configuration in one of the laptops:
user@debian:~$ fbset -i
mode "3840x2160"
geometry 3840 2160 3840 2160 32
timings 0 0 0 0 0 0 0
accel true
rgba 8/16,8/8,8/0,0/0
endmode
Frame buffer device information:
Name : i915drmfb
Address : 0
Size : 33177600
Type : PACKED PIXELS
Visual : TRUECOLOR
XPanStep : 1
YPanStep : 1
YWrapStep : 0
LineLength : 15360
Accelerator : No
Playing with these numbers, I was able to modify the geometry of the console, only to reduce the panel to a tiny square in the console display (with equally small fonts anyway). If it was possible to scale or resize the panel in other way, I was unable to understand how to do so by reading the associated docs.
One day, out of despair, I tried disabling kernel modesetting (or KMS). It indeed got me a more readable tty1, only to prevent the whole graphic stack from starting, with Xorg complaining about the lack of kernel modeset.
After lots of wasted time, I decided to blame the NVIDIA graphic card. Because why not: a closed source module in my system looks fishy.
I registered in their official forum and wrote a message about my suspicion on the module, asking for advice on how
to modify the driver default resolution. I was hoping that something like modprobe nvidia my_desired_resolution=1920x1080
could
exist. Apparently not :-(
I was about to give up. I had walked every corner of the known internet. I even tried summoning the ancient gods, I used ChatGPT. I asked the AI god for mercy, for a working solution… to no avail.
Then I decided to change the kind of queries I was issuing the search engines (don’t ask me, I no longer remember). Eventually I landed in this askubuntu.com page. The question described the exact same problem I was experiencing. Finally, that was encouraging! I was not alone in my adventure after all!
The solution section included a font size I hadn’t seen before in my previous tests: 16x32
. More excitement!
I did all the steps. I installed the xfonts-terminus
package, and in the file /etc/default/console-setup
I put:
ACTIVE_CONSOLES="/dev/tty[1-6]"
CHARMAP="ISO-8859-15"
CODESET="guess"
FONTFACE="Terminus"
FONTSIZE="16x32"
VIDEOMODE=
Then I run setupcon
from a tty, and… the miracle happened! I finally got a bigger font in the tty1 console!
Turned out a potential solution was about playing with console-setup
, which I had tried wihtout success before.
I’m not even sure if the additional package was required.
This is how my console looks now:
The truth is… the solution is satisfying only to a degree. I’m a person with good eyesight and can work with these bit larger fonts. I’m not sure if I can get larger fonts using this method, honestly.
After some search, I discovered that some folks already managed to describe the problem in detail and filed a proper bug report in Debian, see #595696… opened more than 10 years ago.
2023 is the year of linux on the desktop
Nope.
I honestly don’t see how this disconnected pile of settings can be all reconciled together.
Can we please have a systemd-whatever
that homogeinizes all of this mess?
I’m referring to grub + kernel drivers + console + lightdm + XFCE4.
Next adventure
When I lock the desktop (with CTRL+ALT+L
) and close the laptop lid to suspend it, then reopen it, type the login info
into the lightdm greeter, then the desktop environment never loads, black screen.
I have already tried the first few search results without luck. Perhaps the nvidia card is to blame this time? Perhaps poorly coupled power management by the different system software pieces?
Who knows what’s going on here. This will probably be my next Debian desktop adventure.