You are not logged in.

#1 2017-10-19 20:42:33

NuSkool
Member
Registered: 2015-03-23
Posts: 141

systemd Change default login tty [SOLVED]

Running xfce without a DM. Using xorg-xinit to startx. Per default, after startup, I get a login prompt on tty1 and all is good.

However, I'd like to change the default behaviour to be dropped at a login prompt on tty6 (or whatever) without having to manually Ctrl+Alt+F6.

I've read this: https://wiki.archlinux.org/index.php/getty, which states: "If you want to use a tty other than tty1, see systemd FAQ."
which links to this: https://wiki.archlinux.org/index.php/Sy … _gettys.3F.

However, I'm still not getting it. I've tried both manually adding and deleting the files, /etc/systemd/system/getty.target.wants/getty@tty1.service and getty@tty6.service. Alternatively also used systemctl to enable and disable them. As a test, (I know this is bad) also editing last line of /usr/lib/systemd/system/getty@.service DefaultInstance=tty1 to DefaultInstance=tty7, and combinations of all the above.

I've searched using variations of arch "systemd default" getty, tty, vt, login, etc, read man logind.confd, logind.conf, loginctl, etc.

Only difference I've noticed during testing is if I delete/disable getty@tty1.service, upon reboot, don't get a login prompt in tty1. I can switch tty's to login though, dynamically started getty's per systemd.

Also possibly relevant is a noclear.conf file in /etc/systemd/system/getty@tty1.service.d/.

Seems what I'm trying to do should be pretty pretty straight forward as all the DM's I've used, use tty7. Guess I could try write a script or just Ctrl+Alt+N, but thinking I'm missing something and there has to be a simple solution.


.xinitrc:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

#--------------------------------------

if [ -f $sysresources ]; then

    xrdb -merge $sysresources

fi

#--------------------------------------

if [ -f $sysmodmap ]; then

    xmodmap $sysmodmap
fi

#--------------------------------------

if [ -f "$userresources" ]; then

    xrdb -merge "$userresources"

fi

#--------------------------------------

if [ -f "$usermodmap" ]; then

    xmodmap "$usermodmap"

fi

#--------------------------------------

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

#--------------------------------------

# twm &
# xclock -geometry 50x50-1+1 &
# xterm -geometry 80x50+494+51 &
# xterm -geometry 80x20+494-0 &
# exec xterm -geometry 80x66+0+0 -name login  

exec startxfce4 

.xserverrc:

#!/bin/sh

exec /usr/bin/Xorg -keeptty -nolisten tcp "$@" vt$XDG_VTNR

/etc/systemd/system/getty@tty1.service.d/noclear.conf

[Service]
TTYVTDisallocate=no

systemctl results of a test:

$ systemctl | grep tty
sys-devices-pci0000:00-0000:00:12.0-usb3-3\x2d2-3\x2d2:1.0-ttyUSB0-tty-ttyUSB0.device     loaded active plugged   PL2303 Serial Port                                                                  
sys-devices-pci0000:00-0000:00:12.0-usb3-3\x2d3-3\x2d3:1.0-ttyUSB1-tty-ttyUSB1.device     loaded active plugged   PL2303 Serial Port                                                                  
sys-devices-platform-serial8250-tty-ttyS1.device                                          loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS1                                          
sys-devices-platform-serial8250-tty-ttyS2.device                                          loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS2                                          
sys-devices-platform-serial8250-tty-ttyS3.device                                          loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS3                                          
sys-devices-pnp0-00:03-tty-ttyS0.device                                                   loaded active plugged   /sys/devices/pnp0/00:03/tty/ttyS0                                                   
getty@tty6.service                                                                        loaded active running   Getty on tty6                                                                       
system-getty.slice                                                                        loaded active active    system-getty.slice                                                                  
getty.target                                                                              loaded active active    Login Prompts                

179

Last edited by NuSkool (2017-10-20 23:28:56)

Offline

#2 2017-10-20 06:44:35

mpan
Member
Registered: 2012-08-01
Posts: 1,207
Website

Re: systemd Change default login tty [SOLVED]

Both linked pages deal with setting up getty to be present on given TTYs, not switching to TTY. What you want is probably running chvt 6 somewhere at the start of your system.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2017-10-20 21:38:36

NuSkool
Member
Registered: 2015-03-23
Posts: 141

Re: systemd Change default login tty [SOLVED]

Through more detailed research and more trial & error, figured this out. Either this info is not documented anywhere I could find, or I didn't use the proper search terms. The following may help others wanting to do similar, not knowing how.

Firstly thanks mpan, you broke my misplaced tunnel vision on a systemd config or setting.

Then I'd like to thank those who could have answered this question off top of their heads with a single sentence (you know who you are). This confirms I need to start using my identy obscured profile. Note to self: stop using this one now.

Long story short, a very simple solution, just lacked a bit of direction initially.

1) Created a one line script "change.login.tty" in ~/bin
2) Created a systemd service file, "change.login.tty.service" in /etc/systemd/system/ 
3) Enabled "change.login.tty.service"

systemctl enable change.login.tty.service

4) Edited /etc/systemd/logind.conf to, #NAutoVTs=7 and #ReserveVT=7
5) Start getty on tty7, (likely not necessary)

systemctl enable getty@tty7

6) Reboot, login at prompt on tty7 and enjoy.

I played around a bit with kernel paramater "console=N" which leads me to consider the possibility that the kernel may actually set the "login ttyN" rather than systemd, but just a hunch.


~/bin/change.login.tty

#!/bin/bash
# This changes the login tty #

chvt 7

/etc/systemd/system/change.login.tty.service

[Unit]
Description=Change login tty number.

[Service]
Type=idle
ExecStart=/home/[user name]/bin/change.login.tty

[Install]
WantedBy=multi-user.target 

/etc/systemd/logind.conf

#  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.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=7
#ReserveVT=7
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%

Please correct errors or simpler solutions via posting, rather that just pointing out errors. It worked for me, your results may vary.
If this gets deleted or obscured from searches ie: tgn, db. I can put it up on my blog for easy search indexing.

Last edited by NuSkool (2017-10-21 18:31:59)

Offline

#4 2024-03-28 10:56:40

mmontu
Member
Registered: 2024-03-28
Posts: 1

Re: systemd Change default login tty [SOLVED]

Thanks NuSkool, your solution helped me after spending a couple of hours on this.
It seems steps 4 and 5 are not necessary.

Offline

Board footer

Powered by FluxBB