Cannot disable systemd serial-getty service

lojoe picture lojoe · Feb 6, 2014 · Viewed 17.5k times · Source

On Raspberry Pi with Arch Linux there is a service active called serial-getty@AMA0.

The unit file is: /usr/lib/systemd/system/[email protected]

As root I can invoke

systemctl stop serial-getty@ttyAMA0
systemctl disable serial-getty@ttyAMA0

But after reboot the service is enabled and running again.

Why is the service enabled after disabling it? How can I disable it permanent?

UPDATE

systemd uses generators at /usr/lib/systemd/system-generators/ is a binary called systemd-getty-generator. This binary runs at system start and adds the symlink [email protected] to /run/systemd/generator/getty.target.wants.

I eventually found a dirty solution. I commented out all actions in /usr/lib/systemd/system/[email protected]. The service did appear to start anyway, but without blocking ttyAMA0.

Answer

Rob Meades picture Rob Meades · Mar 12, 2014

The correct way to stop a service ever being enabled again is to use:

systemctl mask [email protected]

(using ttyAMA0 as the example in this case). This will add a link to null to the entry for that service.