0

This question is different from the possible candidate since here I am asking how to remove the service at startup

I am using a Seeed ReSpeaker Core v2.0 board. I would like to use the UART interface to make this board communicate with another one. But the UART port /dev/ttyS2 is linked to the console. I have identified a service linked to the board and I would like to disable it in order to prevent it from starting at boot:

userk@glutamate:~$ sudo systemctl status | grep ttyS2
           │ │ ├─[email protected]
           │ │ │ └─1078 /sbin/agetty --keep-baud 115200,38400,9600 ttyS2 vt220
               │ ├─1093 grep ttyS2

There is no information related to the bootloader on the official page. I already asked a question on their forum.

EDIT 0

the service is statically enabled

userk@glutamate:~$ systemctl list-dependencies --reverse serial-getty@ttyS2
[email protected]
● └─getty.target
●   └─multi-user.target
●     └─graphical.target

When I stop and disable it, the situation seems fine:

userk@glutamate:~$ sudo systemctl stop [email protected] 
userk@glutamate:~$ sudo systemctl disable [email protected] 
userk@glutamate:~$ sudo systemctl status | grep ttyS2
               │ ├─1135 grep ttyS2

But when I reboot the system, it appears again.

EDIT 1

  • I am working with Debian 9 (stretch). I used an image made by SeedStudio.
  • I asked another question related to this service here. As @JdeBP stated in his answer

The fundamental configuration item that drives this is the console setting that one gives on the command line to the kernel via the boot loader. It's that that tells the generator what serial console services to start. It is that that tells the kernel where to send kernel console output. It is that that tells the kernel where to send /dev/console output. If you do not want your serial device to be a console, it is that that you need to adjust.

EDIT 2

I cannot find the [email protected] in /lib/systemd/system folder. I am using grep -rl [email protected] /lib/systemd/system.

13
  • 2
    In unix.stackexchange.com/a/475043/5132 I mentioned the console setting. This question could be improved by telling answerers what that setting now is.
    – JdeBP
    Nov 6, 2018 at 14:48
  • 1
    If you are not sure what bootloader the board uses and how to configure it, you can start by ruling this in or out by checking cat /proc/cmdline, i.e. seeing if it contains console=ttyS2
    – sourcejedi
    Nov 6, 2018 at 15:09
  • 3
    Possible duplicate of Getting rid of a serial console on Respeaker Core V2
    – sourcejedi
    Nov 6, 2018 at 15:30
  • 1
    @UserK then you are asking about how to change the options passed by the bootloader, but this question has no information about which bootloader software is being used, this question doesn't even tell us what the hardware is so we can guess what the bootloader is :-). I would have taken the original question to imply that you would also want to disable it on startup, since that is what systemctl disable does for most services.
    – sourcejedi
    Nov 6, 2018 at 16:05
  • 1
    it is possible - "A symlink to /dev/null or an empty file can be used to mask a generator, thereby preventing it from running." - so you can mask systemd-getty-generator
    – sourcejedi
    Nov 6, 2018 at 16:17

2 Answers 2

3

Following EDIT2, this answer is obsolete.


Note that you're not supposed to write configuration like that to /lib/. I hope you (or another admin) simply created it there by mistake, and there is not a more complex problem. In that case you can just revert it, i.e.

rm /lib/systemd/system/getty.target.wants/[email protected]

Then you can reboot. (Or run systemctl daemon-reload, and check again to see that the service has been disabled properly).

Before deleting the file, I might double-check that the unwanted link is not provided by a package

dpkg-query -S /lib/systemd/system/getty.target.wants/[email protected]

and that it is indeed a symlink

ls -l /lib/systemd/system/getty.target.wants/[email protected]

You can also check for other files which were placed inappropriately by an admin. Install the Debian package cruft, and run cruft -d "/lib/systemd/system".

2
  • I am sorry @sourcejedi but I was wrong about the symlink. As I wrote in the EDIT2 section, I cannot find any [email protected] in /lib/systemd/system folder.
    – UserK
    Nov 6, 2018 at 15:06
  • I upvoted your answer for the content you have provided
    – UserK
    Nov 6, 2018 at 15:34
1

0. about [email protected]

$ sudo systemctl status [email protected][email protected] - Serial Getty on ttyS0
     Loaded: loaded (/lib/systemd/system/[email protected]; enabled-runtime; vendor preset: enabled)
     Active: active (running) since Wed 2022-06-08 02:20:07 CST; 2min 7s ago
       Docs: man:agetty(8)
             man:systemd-getty-generator(8)
             http://0pointer.de/blog/projects/serial-console.html
   Main PID: 420 (agetty)
      Tasks: 1 (limit: 4336)
        CPU: 12ms
     CGroup: /system.slice/system-serial\x2dgetty.slice/[email protected]
             └─420 /sbin/agetty -o -p -- \u --keep-baud 115200,57600,38400,9600 ttyS0 vt220

1. about systemd-getty-generator

man systemd-getty-generator
https://man.archlinux.org/man/systemd-getty-generator.8.en

This stuff parse console= from /proc/cmdline, and
 generator (and enable) serial-getty@ instance [email protected]
at each system boot.


2. stop haunted

A. disable systemd-getty-generator

sudo chmod -x /lib/systemd/system-generators/systemd-getty-generator

to stop this haunted stuff



OR

B. change kernel cmdline in bootloader

remove console=ttyS0 stuff

cat /proc/cmdline to verify

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .