You are not logged in.

#1 2018-06-04 12:59:17

ss
Member
Registered: 2018-06-04
Posts: 89

[SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

UPDATE:
See berbae's post which finally fixed my problem, although I can no longer determine whether it was the only change required. Thanks for all the answers and suggestions!

-------------------

ORIGINAL POST:

I want to set the default keyboard layout to de-latin1 and change the console font in linux console. I edited /etc/vconsole.conf as following, but still get an English keyboard at the end.

# cat /etc/vconsole.conf
KEYMAP=de-latin1
FONT=ter-g16n

The service systemd-vconsole-setup has error.

# journalctl | grep vconsole
Jun 04 13:19:23 m1 systemd-vconsole-setup[335]: /usr/bin/setfont failed with exit status 65.
Jun 04 13:19:23 m1 systemd-vconsole-setup[335]: Setting source virtual console failed, ignoring remaining ones
Jun 04 13:19:23 m1 systemd-udevd[275]: Process '/usr/lib/systemd/systemd-vconsole-setup' failed with exit code 1.

(EDIT: If I leave out the FONT setting in vconsole.conf, it understandably won't produce error about /usr/bin/setfont, but the keyboard layout is still not set.)

However, if I manually run /usr/lib/systemd/systemd-vconsole-setup after login in a shell, it works. I get both the desired keyboard layout and console font. Here is the systemd service file.

# cat /usr/lib/systemd/system/systemd-vconsole-setup.service

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Setup Virtual Console
Documentation=man:systemd-vconsole-setup.service(8) man:vconsole.conf(5)
DefaultDependencies=no
Before=initrd-switch-root.target shutdown.target
ConditionPathExists=/dev/tty0

[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/systemd-vconsole-setup

I also tried various solutions I found in this post https://bbs.archlinux.org/viewtopic.php?id=168810, including adding my graphics card module in /etc/mkinitcpio.conf and run mkinitcpio -p linux, as well as adding After=/Wants= in the systemd service file, but none of them helped.

localectl set-keymap works, but only in X, not in linux console.

# localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: de-latin1
      X11 Layout: de
       X11 Model: pc105
     X11 Variant: nodeadkeys

As a last resort, I took the advice of another solution I found in the internet and made a custom systemd service to set keymap and font. It actually works, but kinda ugly.

# cat /etc/systemd/system/vconsole-fix.service
[Unit]
Description=Fix Virtual Console
Before=-.mount
ConditionPathExists=/dev/tty0

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-vconsole-setup

[Install]
WantedBy=multi-user.target

From what I can see, the font and keyboard layout were reset during the boot up process, and systemd-vconsole-setup was not executed at the right timing. But I have no idea how to get it right. Could anybody help?

Apropos, I am actually using a laptop, so the keyboard is certainly not pc105. But how can I know which keyboard variant I am actually having?

Last edited by ss (2018-06-05 10:24:59)

Offline

#2 2018-06-04 16:11:19

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,046
Website

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

Use journalctl _PID=XXX to determine why the service fails.


Not an Installation issue, moving to Apps & DEs.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-06-04 17:45:26

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

The service failed because /usr/bin/setfont failed with exit status 65. How could I proceed to find out what the actual meaning of exit code 65 of this specific program is and how to solve it?

Furthermore, I doubt that was the real reason behind the fail (font and keymap not set correctly at the end), as discussed in this post https://bbs.archlinux.org/viewtopic.php?id=146743. I guess the font and keymap was actually set during the boot and then reset by the graphics module, because the font type change can be clearly observed during the bootup. However, the early KMS setting, which was proposed as solution in the above-mentioned post,  didn't work for me. I have an Nvidia card and the following setting in the relevant file. 

# cat /etc/mkinitcpio.conf

MODULES=(nouveau ahci sd_mod ext4)

The posts about this issue were all a few years old, but after reading through them, I can't draw a definite conclusion out of the discussions. I would be grateful if anyone could give me a hint about what to look for next.

Offline

#4 2018-06-04 17:49:30

tpfkanep
Member
From: South Africa
Registered: 2009-12-15
Posts: 109

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

Do you have "consolefont" in the HOOKS line in mkinitcpio.conf?

Offline

#5 2018-06-04 17:54:22

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,046
Website

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

ss wrote:

The service failed because /usr/bin/setfont failed with exit status 65. How could I proceed to find out what the actual meaning of exit code 65 of this specific program is and how to solve it?

jwr wrote:

Use journalctl _PID=XXX to determine why the service fails.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2018-06-04 19:12:49

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

jwr wrote:

Use journalctl _PID=XXX to determine why the service fails.

OK, I was not ignoring your instruction. I did actually try that, but was not able to get any new insight from the result. Maybe I was not doing it right?

Here is the output of journalctl _PID=XXX

-- Logs begin at Sun 2018-06-03 16:38:04 CEST, end at Mon 2018-06-04 21:02:17 CEST. --
Jun 04 02:29:30 m1 systemd-fsck[335]: /dev/sda2: clean, 369/32768 files, 56610/131072 blocks
-- Reboot --
Jun 04 13:19:23 m1 systemd-vconsole-setup[335]: /usr/bin/setfont failed with exit status 65.
Jun 04 13:19:23 m1 systemd-vconsole-setup[335]: Setting source virtual console failed, ignoring remaining ones

I also went through the output of journalctl --output=verbose quasi manually, but still couldn't find any new hints. Failed with exit code 65 was pretty much all it said.

Offline

#7 2018-06-04 19:19:12

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

tpfkanep wrote:

Do you have "consolefont" in the HOOKS line in mkinitcpio.conf?

Now I have added consolefont to HOOKS then rebuilt initramfs. But the result is the same.

Offline

#8 2018-06-05 09:01:53

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

jasonwryan wrote:

Not an Installation issue, moving to Apps & DEs.

I respect your decision and we can just leave the post here in this section. However, I would also like to make clear that I did not mindlessly post it to the installation section. For users with non-US keyboards, making a persistent change to the keyboard layout is an essential part of installation, because you can barely use a system with a wrong keyboard. One simple case is that you will struggle to login after the reboot if the password includes some special characters. Moreover, it is a royal pain to use the command line interface and edit config files when you are not sure where to find the |#*&/~>< etc. 

In the Arch installation guide, it is described that editing /etc/vconsole.conf is the way to make the desired keyboard layout persistent. I followed the instruction, but had problems to make it work. That's why I thought this is a topic related to the installation.

Offline

#9 2018-06-05 09:06:39

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,298

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

This works for me:

grep '^HOOKS' /etc/mkinitcpio.conf
HOOKS=(base systemd autodetect modconf block filesystems keyboard sd-vconsole fsck)

for a french keyboard layout

cat /etc/vconsole.conf
KEYMAP=fr-latin9
FONT=eurlatgr

Offline

#10 2018-06-05 10:16:49

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] Can't set KEYMAP and FONT in /etc/vconsole.conf

berbae wrote:

This works for me:

grep '^HOOKS' /etc/mkinitcpio.conf
HOOKS=(base systemd autodetect modconf block filesystems keyboard sd-vconsole fsck)

Thank you! It fixed my problem. I added systemd and sd-vconsole to HOOKS, then everything works as intended.

Though strangly enough I still see the error about /usr/bin/setfont in journalctl. But I can confirm that the consolefont is correctly set. Most importantly, also the annoying font change during boot up is gone.

Offline

Board footer

Powered by FluxBB