nixos-rebuild switch
fails in X console with
â—Ź systemd-vconsole-setup.service - Setup Virtual Console
Loaded: loaded (/nix/store/zs7cny1d4g81m5fvggj8jg4d5s9wrmb2-systemd-232/example/systemd/system/systemd-vconsole-setup.service; enabled; vendor preset: enabled)
Drop-In: /nix/store/5bjicxls5f25bg90qyilkpx26iy43hgq-system-units/systemd-vconsole-setup.service.d
└─overrides.conf
Active: failed (Result: exit-code) since Sun 2017-02-05 20:18:54 UTC; 1s ago
Docs: man:systemd-vconsole-setup.service(8)
man:vconsole.conf(5)
Process: 15186 ExecStart=/nix/store/zs7cny1d4g81m5fvggj8jg4d5s9wrmb2-systemd-232/lib/systemd/systemd-vconsole-setup (code=exited, status=1/FAILURE)
Main PID: 15186 (code=exited, status=1/FAILURE)
CPU: 3ms
Feb 05 20:18:54 x220b systemd[1]: Starting Setup Virtual Console...
Feb 05 20:18:54 x220b systemd[1]: systemd-vconsole-setup.service: Main process exited, code=exited, status=1/FAILURE
Feb 05 20:18:54 x220b systemd[1]: Failed to start Setup Virtual Console.
Feb 05 20:18:54 x220b systemd[1]: systemd-vconsole-setup.service: Unit entered failed state.
Feb 05 20:18:54 x220b systemd[1]: systemd-vconsole-setup.service: Failed with result 'exit-code'.
warning: error(s) occurred while switching to the new configuration
/nix/store/zs7cny1d4g81m5fvggj8jg4d5s9wrmb2-systemd-232/lib/systemd/systemd-vconsole-setup
exits with
Virtual console /dev/tty0 is not in K_XLATE or K_UNICODE.
In Ctrl-Alt-F1
console it works without the problem.
just run nixos-rebuild switch
System: (NixOS: nixos-version
, Ubuntu/Fedora: lsb_release -a
, ...)
17.03.git.5de7d45 (Gorilla)
Nix version: (run nix-env --version
)
nix-env (Nix) 1.11.6
Nixpkgs version: (run nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion
)
"17.03.git.5de7d45c91"
Just ran into this very issue.
Output from the journal:
Feb 07 21:20:10 yuu systemd[1]: Stopped Setup Virtual Console.
Feb 07 21:20:10 yuu systemd[1]: Starting Setup Virtual Console...
Feb 07 21:20:10 yuu systemd[1]: systemd-vconsole-setup.service: Main process exited, code=exited, status=1/FAILURE
Feb 07 21:20:10 yuu systemd[1]: Failed to start Setup Virtual Console.
Feb 07 21:20:10 yuu systemd[1]: systemd-vconsole-setup.service: Unit entered failed state.
Feb 07 21:20:10 yuu systemd[1]: systemd-vconsole-setup.service: Failed with result 'exit-code'.
Trying to manually start it:
Job for systemd-vconsole-setup.service failed because the control process exited with error code.
See "systemctl status systemd-vconsole-setup.service" and "journalctl -xe" for details.
Can someone explain what impact this has? What should I do now?
Pinging some ppl which are involved with the systemd environment (from what I see): @abbradar @shlevy
systemd-vconsole-setup
sets fonts and keymaps for kernel consoles (Ctrl+Meta+F{1..6}). This should be harmless, they will be picked up at next boot. Not sure if we can improve this, too (you can't set kernel console settings if it's not active currently).
EDIT: You actually can; thanks to @lucas8 for investigation -- see below.
@abbradar thanks for that quick reply. Good to know that it is harmless.
My nix-script
call failed, so I did not get the git tag
s in my configuration, so I'd opt for "Fix it", but I'm kinda biased :smile:
I agree that we should fix it, just not sure how -- I think I've seen this behaviour as far as in Arch some six years ago.
Maybe we should decline to restart vconsole-setup?
(similar to how we don't restart display-manager when it changes)
Not an ideal solution (for one who runs nixos-rebuild switch
in a kernel terminal to test new keymap or whatnot) but not bad. I vote going for it.
IMHO, the warning: error(s) occurred while switching to the new configuration
bit means that this ought to be fixed in some way; that's not a good user experience at all. @shlevy's suggestion sounds like a good-enough solution for the time being to me.
Thanks @shlevy for suggestion!
We do not deviate from upstream systemd? That's nice! :+1:
That's my bad wording :D We still do add Before``/After
s which could be considered a deviation. It's just that this comment seems to come from time when we completely redefined this unit -- now all changes are visible explicitly.
Just wanted to add that
~bash
$ sudo kbd_mode -C /dev/tty0 -u
~
seems to fix the issue temporarily (until next reboot, I think).
IIRC once I had a problem when trying to switch
a system over ssh :-) but maybe that doesn't happen anymore.
Same here with the last update of nixos-unstable
also, systemctl status
:
State: degraded
Jobs: 0 queued
Failed: 1 units
because of that.
The issue persists for me as well.
I encountered this issue as well, and was able to pin it down :
systemd-vconsole-setup.service
calls systemd-vconsole-setup
without arguments.systemd-vconsole-setup
without arguments first run on /dev/tty0
/dev/tty0
is K_OFF
.K_XLATE
nor K_UNICODE
, vconsole-setup
failsAfter some testing, it turns out that all terminals are in K_UNICODE
, except for /dev/tty7
(which is to be expected, as it is the X terminal) and /dev/tty0
.
From here I see two possible solutions :
/dev/tty0
keyboard mode to K_UNICODE
: I don't know why it is set to K_OFF
, and maybe there is a good reason so I'm not sure about this solution. This is what @SuprDewd solution is doing.systemd-vconsole-setup.service
by passing /dev/tty1
as first argument of systemd-vconsole-setup
. I would have proposed a patch myself but I do not understand nix syntax well enough for that.@volth Oh, indeed -- I hoped it would work for oneshot too.
@lucas8 Great investigation! If I understand correctly, /dev/tty0
is the current console, so when you use X you essentially have /dev/tty0 -> /dev/tty7
.
Not sure if setting it to /dev/tty1
would make it work correctly. Would that work for /dev/tty2
and above?
@abbradar : Yes, and that would explain why /dev/tty0
is K_OFF
when in X, and also why it would work when you're not in X. I didn't test, but normally it would work for any /dev/tty*
with K_XLATE
or K_UNICODE
. So we should set the argument to a /dev/tty.
which we are sure : exists everytime and is not a X terminal. So /dev/tty{1..6}
could be used (as long as the user doesn't manually start an X server from one of those terminals).
What I'm unsure of is that would that also set fonts/keymaps on other terminals if set for /dev/tty1
. We can just do an experiment though.
/dev/tty
, according to this answer, is the terminal that the process was started in -- it would mean closely the same as /dev/tty0
.
From the vconsole-setup
source code, the flow of the program is the following :
/dev/tty0
if none is provided.K_XTRANS
or K_UNICODE
(that's how it checks it is not an X terminal). If that's not the case it fails.K_XTRANS
nor K_UNICODE
do nothing to them.That's why, for it to work, vconsole-setup
needs to set the font one first terminal, which is the one it asks as argument, and is the one that must be settable. The others terminal can be skipped if they are not settable.
So it should set the fonts/keymaps to the others terminal if it has an argument.
@lucas8 Awesome, thank you again! It seems strange that they need an argument at all and not just loop over everything in this case.
I'll make a patch to set this to /dev/tty1
later.
Fixed; along with https://github.com/NixOS/nixpkgs/commit/109ee2a338eeff0d6be820e2caa2950922124cf1 fonts are also properly set on switch
in all cases, too. I've opened https://github.com/systemd/systemd/issues/5367 to track this upstream.
@volth Seems so but I'm unsure what was the aim. BTW kmscon seems abandoned, I have believed it doesn't work at all nowadays...
@abbradar, kmscon may be abandoned but it works great on my hidpi laptop.
@volth, why would you want the unit to be restarted if changed?
A oneshot service can definitely be restarted.
[Unit]
Description=Woot
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo WOOOOOT!'
If you restart this, it does what you would expect. But I would imagine that systemd-vconsole-setup only changes if the device changes (via the override) and in that case wouldn't you want it to be run?
I still get this with master.
Strange; I've tried just now and the service started correctly while in X11.
What is the exact error you see?
The error in the OP. I just disabled kmscon, restarted, it works now.
Fixed that with kmscon in 516a7fc7bdd5.
FYI, this workaround currently breaks gdm which runs on tty1 by default.
We could change /dev/tty1
to /dev/tty2
(which isn't used by any mainstream login manager I think), but that feels a bit too hackish. Maybe we could write a little wrapper which first discovers a terminal with
the right keyboard mode, by looping over /dev/tty{0..6}
.
The workaround is also not effective on my machine where gdm is used. :(
I still encounter this on my machine. This is what I get when i run nixos-rebuild switch. Actually this is happening only when GDM's in use not with other display-managers.
$ sudo nixos-rebuild switch
building Nix...
building the system configuration...
activating the configuration...
setting up /etc...
setting up tmpfiles
warning: the following units failed: systemd-vconsole-setup.service
â—Ź systemd-vconsole-setup.service - Setup Virtual Console
Loaded: loaded (/nix/store/9fvib0d8f83zf8jxa0m2drq3xiffg4lp-systemd-232/example/systemd/system/systemd-vconsole-setup.service; enabled; vendor preset: enabled)
Drop-In: /nix/store/hxndr7z4a8lv8k5ky07bqsr8xl5fdjbd-system-units/systemd-vconsole-setup.service.d
└─overrides.conf
Active: failed (Result: exit-code) since Fri 2017-08-18 19:35:04 CEST; 31ms ago
Docs: man:systemd-vconsole-setup.service(8)
man:vconsole.conf(5)
Process: 10211 ExecStart=/nix/store/9fvib0d8f83zf8jxa0m2drq3xiffg4lp-systemd-232/lib/systemd/systemd-vconsole-setup /dev/tty1 (code=exited, status=1/FAILURE)
Main PID: 10211 (code=exited, status=1/FAILURE)
Aug 18 19:35:04 nixOs systemd[1]: Starting Setup Virtual Console...
Aug 18 19:35:04 nixOs systemd[1]: systemd-vconsole-setup.service: Main process exited, code=exited, status=1/FAILURE
Aug 18 19:35:04 nixOs systemd[1]: Failed to start Setup Virtual Console.
Aug 18 19:35:04 nixOs systemd[1]: systemd-vconsole-setup.service: Unit entered failed state.
Aug 18 19:35:04 nixOs systemd[1]: systemd-vconsole-setup.service: Failed with result 'exit-code'.
warning: error(s) occurred while switching to the new configuration
However rebuild will succed despite the error warning.
Same here. Reopening. And since the exit status of nixos-rebuild is non-zero, the nixos-upgrade service (system.autoUpgrade.enable = true;
) is always marked as "failed".
@bjornfor Do you also get this only with GDM?
@abbradar: I haven't tested anything other than GDM (I have GNOME on all machines).
This issue is related https://github.com/NixOS/nixpkgs/issues/24172 adding the work around https://github.com/NixOS/nixpkgs/issues/24172#issuecomment-330121154 fixes this issue as well.
The problem is quite simple. Only GDM runs on tty1, others display managers use tty7 and NixOS is not ready to run DMs on tty1.
Simple change in gdm packages like this will fix this.
@deedrah thanks for the clarification.
The underlying issue is fixed in systemd 234.
Removing the workaround (calling systemd-vconsole-setup on /dev/tty1) and thus converging to upstream's .service file is the correct solution.
There is second problem caused by this change in the upstream systemd-vconsole-setup.service unit.
NixOS contains only halve of the change. The RemainAfterExit=yes
was removed, but the service is still wanted by sysinit.target
. Systemd expects now, that vconsole-setup is started by udev (and only) during a boot.
That foced nixos-rebuild to start systemd-vconsole-setup.service on every configuration switch and the bug in systemd-vconsole-setup binary cloud show up.
I propose to give systemd-vconsole-setup.service the RemainAfterExit=yes
back, which should fix issue #23118, too. nixos-rebuild should (re)start systemd-vconsole-setup when switching configurations only if there is a change in console configuration.
On the other hand, just removing wantedBy = [ "sysinit.target" ];
is OK, too and is closer to upstream.
If the first solution will be reverted, then forcing GDM on tty7 is no longer not relevant in this issue, however there are other problems with GDM on tty1.
For GDM, see #29697.
Also removed wantedBy = [ "sysinit.target" ]
in addition to remove the tty1 workaround by merging #29576.
Thanks a lot @deedrah for your analysis!
Most helpful comment
Not an ideal solution (for one who runs
nixos-rebuild switch
in a kernel terminal to test new keymap or whatnot) but not bad. I vote going for it.