HiDPI console font non-interactive
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
?
Solution 1:
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