Track Down Wrapped Init Scripts with systemd-sysv-generator

Reload systemd and a service you swore was hand-configured turns out to be a wrapper: systemd-sysv-generator just imported it from /etc/init.d/. This guide shows you how to find that script, read the generated unit it produced, and check the ordering and boot targets it was given. Allow about 10 minutes.

You need a shell account that can read the service files; reach for sudo only where a step needs privileged access.

What the generator actually does

/usr/lib/systemd/system-generators/systemd-sysv-generator

Do not run that path to start or stop a service. Use systemctl for service operations and let systemd invoke its generators in the background.

1. Find the legacy script

List the script named by the service you are investigating. Replace the placeholder with a real service name; this is a read-only command and does not need elevated privileges.

SERVICE_NAME=example-daemon
ls -l "/etc/init.d/$SERVICE_NAME"
sed -n '1,100p' "/etc/init.d/$SERVICE_NAME"

Look for an LSB header between ### BEGIN INIT INFO and ### END INIT INFO. Fields such as Required-Start, Required-Stop, Should-Start, Default-Start and Default-Stop describe ordering and runlevel intent. A script without useful headers can still be wrapped, but systemd has less to go on when ordering it.

Checkpoint: you should have a real file below /etc/init.d/. If it is missing, you are probably looking at a native unit, or a service name from a different package entirely.

2. Ask systemd which unit is active

Use the service name with a .service suffix. Neither command changes service state:

systemctl status "$SERVICE_NAME.service" --no-pager
systemctl cat "$SERVICE_NAME.service"

3. Inspect dependencies and boot placement

Ask systemd to show the unit's effective ordering and relationships:

systemctl show "$SERVICE_NAME.service" \
  -p FragmentPath -p SourcePath -p Type -p Before -p After \
  -p WantedBy --no-pager

Generated units live under /run/systemd/, which is runtime state, not a file you should ever edit directly. The SourcePath points back to the SysV script. If you need to change behaviour, change the package configuration or replace the script with a native unit; edits to the generated file are lost on the next reload or boot.

4. Reload after a script or package change

Generators run when the system manager reloads, so after a package changes an init script, tell systemd to catch up. This is an administrative operation and may need elevated privileges:

sudo systemctl daemon-reload
systemctl cat "$SERVICE_NAME.service"

The second command is your verification step. Compare SourcePath, the ExecStart and ExecStop lines, and the ordering from systemctl show. A reload does not, by itself, start, stop or restart the service.

Common traps

Safety boundary: when replacing a script, record its current start order, stop order, environment and dependencies first. Write a native unit with explicit After=, Wants= or Requires= relationships, test it in a maintenance window, and only remove the old script once you have a verified rollback path.

Done means