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
           │ │ ├─serial-getty@ttyS2.service
           │ │ │ └─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
serial-getty@ttyS2.service
● └─getty.target
●   └─multi-user.target
●     └─graphical.target

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

userk@glutamate:~$ sudo systemctl stop serial-getty@ttyS2.service 
userk@glutamate:~$ sudo systemctl disable serial-getty@ttyS2.service 
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 serial-getty@ttyS2.service in /lib/systemd/system folder. I am using grep -rl serial-getty@ttyS2.service /lib/systemd/system.

  • 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 '18 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 '18 at 15:09
  • 3
    Possible duplicate of Getting rid of a serial console on Respeaker Core V2 – sourcejedi Nov 6 '18 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 '18 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 '18 at 16:17
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/serial-getty@ttyS2.service

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/serial-getty@ttyS2.service

and that it is indeed a symlink

ls -l /lib/systemd/system/getty.target.wants/serial-getty@ttyS2.service

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".

  • I am sorry @sourcejedi but I was wrong about the symlink. As I wrote in the EDIT2 section, I cannot find any serial-getty@ttyS2.service in /lib/systemd/system folder. – UserK Nov 6 '18 at 15:06
  • I upvoted your answer for the content you have provided – UserK Nov 6 '18 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.