在VirtualBox中重新启动时,Ubuntu Server会取消控制台设置

我发现这种奇怪的行为。 在VirtualBox中,Ubuntu Server 12.04使用以下字体:

在此处输入图像描述

我觉得很难读。 现在我可以运行dpkg-reconfigure console-setup ,并将字体设置为Fixed ,然后它看起来像这样:

在此处输入图像描述

这也是它在VMWare中默认显示的方式; 我认为好多了。 有趣的是,启动管理器字体看起来也是这样(即正确加载)。

dpkg-reconfigure console-setup正确更新/etc/default/console-setup文件,但重启后,所有设置都消失了。 出于某种原因,它不会加载console-setup

有谁知道问题可能在哪里? 或者更好,我可以开始寻找?

这是一个错误: 控制台字体没有设置 ,你可以从这里看到补丁。它已在12.10修复,但补丁尚未被移植回12.04。

因此,您可以通过创建具有以下内容的upstart作业/etc/init/console-font.conf来修复它:

 # console-font - set console font # # Set the console font, in case the similar udev rule races with Plymouth # and thus fails to do it. description "set console font" start on starting plymouth-splash task exec /lib/udev/console-setup-tty fbcon 

重启后请参阅ubuntu生动的disrgards-console-setup和https://unix.stackexchange.com/questions/198791/ 。

此问题似乎是由于控制台设置所期望的字体与/usr/share/consolefonts/的字体命名不匹配,因此在您选择要使用的字体时复制到/etc/console-setup/使用dpkg-reconfigure console-setup )。

如果你去一个控制台并做一个strace /lib/udev/console-setup-tty fbcon ,你可以看到它试图打开这样的字体:

 /etc/console-setup/Lat15-TerminusBold11x22.psf 

但是如果你查看/etc/console-setup/ ,那里只有少数字体(你选择的那些),它们看起来更像是这样的:

 /etc/console-setup/Lat15-TerminusBold22x11.psf.gz 

一个具有高度x宽度,另一个具有宽度x高度。

问题可以通过几种方式解决。

(1) /lib/udev/console-setup-tty可以修复 – 这是更永久的上游解决方案。

(2)您可以手动更改/etc/default/console-setup ,在FONTSIZE中反转高度和宽度。 每次使用dpkg-reconfigure console-setup更改字体时都需要执行此操作。 但是当机器重新启动时,保留了这种偏好。

(3)您可以安装console-setup-tty期望的字体。 这就是我称之为“矫枉过正”的选择。 我是这样做的:

在/etc/rc.local中:

 # install console fonts and then set up console /etc/console-setup/fonts.sh install /lib/udev/console-setup-tty fbcon 

创建一个名为/etc/console-setup/fonts.sh的脚本:

 #!/bin/bash action=$1 srcdir="/usr/share/consolefonts" parent="/etc/console-setup" subdir="fonts" case "$1" in install) # console fonts are not named properly in Ubuntu 15.04, compensate [[ -d $parent/$subdir ]] || mkdir $parent/$subdir for x in $( cd $srcdir ; ls -1 ) ; do # rearrange the two numbers from HHxWW to WWxHH y=$(echo "$x" | sed -e 's/^\([^-]*\)-\([^0-9]*\)\([0-9]*\)x\([0-9]*\).psf.gz/\1-\2\4x\3.psf.gz/g') # whether the pattern above matches or not, we'll be uncompressing here z=${y/.psf.gz/.psf} [[ ! -f $parent/$subdir/$z ]] && zcat $srcdir/$x > $parent/$subdir/$z [[ ! -L $parent/$z ]] && ln -sv $subdir/$z $parent/$z done ;; uninstall) rm -rf $parent/$subdir # only remove broken links (links to the fonts we removed above) rm $(find -L $parent -type l) ;; *) echo "$(basename $0) install|uninstall" ;; esac exit 0 

对于快速实用的解决方案,我会做#2,文件中的注释如果您选择不同的字体可能需要重新完成(假设注释也不会被覆盖)。

但#3适用于最小的大惊小怪。