4

What is the correct way to non-interactively change the console font?

I have a HiDPI display and need a larger console font. I can set it interactively just fine using:

$ sudo dpkg-reconfigure console-setup
# Select UTF-8 -> Guess -> Terminus -> 16x32
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.130ubuntu3.5) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-43-generic

However, if I try to set it non-interactively as follows:

 $ sudo debconf-set-selections <<EOF 
 console-setup console-setup/charmap47 select UTF-8
 console-setup console-setup/codeset47 select Guess optimal character set
 console-setup console-setup/codesetcode string guess
 console-setup console-setup/fontface47 select Terminus
 console-setup console-setup/fontsize string 16x32
 console-setup console-setup/fontsize-fb47 select 16x32 (framebuffer only)
 console-setup console-setup/fontsize-text47 select 16x32 (framebuffer only)
 EOF

This does not work. Running setupcon has no effect. If I check /etc/default/console-setup, I see the font info is updated when I run dpkg-reconfigure, and dpkg-reconfigure also triggers update-initramfs, so it seems more is going on with dpkg-reconfigure that my debconf-set-selections does not trigger. How do I find these actions and trigger them after my debconf-set-selections?

1 Answer 1

5

You will need to do this in /etc/default/console-setup file, let's say if we're gonna to use Terminus 16x32 fonts, the command will be:

sudo sed -i '/^FONTFACE/s/^/#/' /etc/default/console-setup # comment out the old value
sudo sed -i '/^FONTSIZE/s/^/#/' /etc/default/console-setup # comment out the old value
echo 'FONTFACE="TER"' | sudo tee -a /etc/default/console-setup # Set font to Terminus
echo 'FONTSIZE="16x32"' | sudo tee -a /etc/default/console-setup # Set font size

And finally, apply your change with sudo update-initramfs -u

Also, Ubuntu kernels (starts from Xenial) will soon support FONT_TER16x32 for console display in early boot stage [1].

To benefit from this HiDPI fonts support, one just need to add "fbcon=font:TER16x32" to the GRUB_CMDLINE_LINUX in /etc/default/grub, and run sudo update-grub

[1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1819881

3
  • Either I've messed up my system testing this, or there is still another step, because this did not work for me. I edited console-setup per your commands, ran update-intramfs, rebooted, and still had a small console font.
    – proximous
    Apr 15, 2019 at 13:57
  • I was using this command for console-setup on a freshly installed Xenial server and it works well.
    – P.-H. Lin
    Apr 24, 2019 at 9:35
  • 2
    I tried the above on a fresh 20.04 and it works so I'm marking this solved with my thanks!
    – proximous
    Jan 5, 2021 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .