Usually, when creating a new systemd unit, snapd
makes two calls to systemctl
:
systemctl daemon-reload
systemctl --root / enable <service>
(see [1] for instance). But, when reading the “enable UNIT” section in the systemctl man page [2], calling daemon-reload
should not be really needed. Quoting:
After the symlinks have been created, the system manager configuration is reloaded (in a way equivalent to daemon-reload), in order to ensure the changes are taken into account immediately.
It also says that calling daemon-reload
might be needed when creating manually symbolic links, which is not the case here. I have done some tests removing the daemon-reload
call from snapd
, and everything has worked as usual when installing a snap, without side effects. Also, I have captured the DBus signals produced by the two calls (with sudo dbus-monitor --system
), and for both enable
and daemon-reload
I get a Reloading
signal and multiple UnitRemoved
/UnitNew
signals, so it all indicates that calling daemon-reload
is redundant.
Note that the cost of this additional call is high: doing a reload in a UC system with 5 snaps installed provokes more than 800 UnitRemoved
/UnitNew
signals (a pair for each unit present in the system). This takes some seconds in slow SoCs. Therefore, removing the additional call would have a nice boost in snap installation times.
[1] https://github.com/snapcore/snapd/blob/master/overlord/snapstate/backend/mountunit.go#L45
[2] https://www.freedesktop.org/software/systemd/man/systemctl.html