I have an in-house config deb that I'm installing on a system. Among other things, I'd like to the package to enable a serial console, as described in http://0pointer.de/blog/projects/serial-console.html.

Appreciating that I could just run systemd enable serial-getty@ttyS0.service in my package's postinst, it feels like it would be better to leverage debhelper in order to ensure proper upgrade/uninstall behaviour. However, I'm finding that:

  • I can't just call dh_systemd_enable from my rules file with the name of an instance unit; it expects to be pointed at an actual file (same thing if I do an end run and try to call deb-systemd-helper directly).
  • I can install a target unit with debhelper, but I don't see to be able to make it do the right thing.

Here's what my target unit looks like:

Description=Serial Console


I can enable and/or start this, and it shows as running under systemctl status, however it doesn't start the instance service which it is supposed to require.

So I guess my question is in two parts: first, why isn't my target unit working as expected, and second, is there a best way to achieve this under Debian packaging?

  1. The Requires directive should appear in the [Unit] section, not in [Install].
  2. But instead ship a /lib/systemd/system/getty.target.wants/serial-getty@ttyS0.service -> /lib/systemd/system/serial-getty@.service symlink in your package. First I assumed that serial-getty@ttyS0.service is automatically pulled in by getty.target if it exists, but such a dependency is only added by systemd-getty-generator for the main kernel console if it's a serial device, which is not the case here. See http://0pointer.de/blog/projects/serial-console.html and man systemd-getty-generator for further details.
  • Can confirm that it works as expected when I install the symlink to the getty.target.wants directory. – mikepurvis Sep 24 '18 at 16:48

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.