5

By default, systemd auto-launches getty on each VT except VT7. What I would like is for systemd to launch top on VT6 instead of getty. Any idea how I configure it to do that?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • What evidence do you have that systemd auto-launches, why do you think this would be configurable or that you'd be able to change this into an interactive program?. And what exactly are you trying to do? – rocky Jun 23 '15 at 09:19
  • Consider, for example, this: http://unix.stackexchange.com/questions/56531/how-to-get-fewer-ttys-with-systemd which explains how to adjust the number of VTs which auto-launch getty. – MathematicalOrchid Jun 23 '15 at 09:33
  • Or indeed http://unix.stackexchange.com/a/194218/5132 . – JdeBP Jun 23 '15 at 21:10

2 Answers2

4

I don't think you can do it on tty6 because:

tty6 is especially reserved for auto-spawned gettys and unavailable to other subsystems such as X[3]. This is done in order to ensure that there's always a way to get a text login, even if due to fast user switching X took possession of more than 5 VTs.

For more info you can check here.

But you can try this on tty5 for example. You can create following service (testo.service or whatever you decide) in /lib/systemd/system/ on most distributions but in openSUSE I think it is /usr/lib/systemd/system:

[Unit]
Description=top on tty5

[Service]
Type=simple
ExecStart=/usr/bin/top
ExecStop=/bin/kill -HUP ${MAINPID}
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty5
Restart=always
RestartSec=2

[Install]
WantedBy=getty.target

And then:

systemctl enable testo.service
taliezin
  • 9,275
  • Worked perfectly first time. Well done! – MathematicalOrchid Jun 23 '15 at 13:41
  • 1
    You've missed the part where you tell logind not to attempt to start autovt@tty5.service or you tell systemd that this is (an alias for) getty@tty5.service. Also note that if all that one wants to do is change ExecStart for one specific instance of the template unit, there's another way to do that. – JdeBP Jun 23 '15 at 21:07
  • @JdeBP i've tested on debian an it worked as expected without additional configuration. Could you elaborate on this so we can improve this answer? – taliezin Jun 23 '15 at 21:14
  • @JdeBP thanks, I will read and try to edit it tomorrow. – taliezin Jun 23 '15 at 21:36
  • https://wiki.archlinux.org/index.php/Automatic_login_to_virtual_console for the second part. logind tries to check to ensure that the virtual terminal isn't already in use, but there's a very small window where this can potentially race with another service, depending from exactly how one activates things. But the alias is definitely necessary if one has, say, explicitly instantiated a getty@tty5.service or followed something like https://fedoraproject.org/wiki/Systemd#How_do_I_set_automatic_login_on_a_virtual_console_terminal.3F . – JdeBP Jun 23 '15 at 21:42
  • @JdeBP The systemd documentation says it only tries to auto-launch getty if the terminal is otherwise unused. Presumably starting top prevents the auto-launch of getty. Works on my OpenSUSE box. – MathematicalOrchid Jun 24 '15 at 08:07
1

What he is trying to do is: have a "top" always available on vt6. Seems like a reasonable goal to me.

The configuration vor the login gettys on the vt's are in /etc/systemd/logind.conf

Here you can restrict systemd on the usage of login-vt's.

What i don't know at the moment is, how the "inittab" functionallity is handled by current distros. "inittab" is where you would have put such a process ...

Maybe this helps? Best regards, gerhard

gerhard d.
  • 2,188