1SYSTEMD.OFFLINE-UPDATES(7)  systemd.offline-updates SYSTEMD.OFFLINE-UPDATES(7)
2
3
4

NAME

6       systemd.offline-updates - Implementation of offline updates in systemd
7

IMPLEMENTING OFFLINE SYSTEM UPDATES

9       This man page describes how to implement "offline" system updates with
10       systemd. By "offline" OS updates we mean package installations and
11       updates that are run with the system booted into a special system
12       update mode, in order to avoid problems related to conflicts of
13       libraries and services that are currently running with those on disk.
14       This document is inspired by this GNOME design whiteboard[1].
15
16       The logic:
17
18        1. The package manager prepares system updates by downloading all
19           (.rpm or .deb or whatever) packages to update off-line in a special
20           directory /var/lib/system-update (or another directory of the
21           package/upgrade manager's choice).
22
23        2. When the user OK'ed the update, the symlink /system-update or
24           /etc/system-update is created that points to /var/lib/system-update
25           (or wherever the directory with the upgrade files is located) and
26           the system is rebooted. This symlink is in the root directory,
27           since we need to check for it very early at boot, at a time where
28           /var/ is not available yet.
29
30        3. Very early in the new boot systemd-system-update-generator(8)
31           checks whether /system-update or /etc/system-update exists. If so,
32           it (temporarily and for this boot only) redirects (i.e. symlinks)
33           default.target to system-update.target, a special target that pulls
34           in the base system (i.e.  sysinit.target, so that all file systems
35           are mounted but little else) and the system update units.
36
37        4. The system now continues to boot into default.target, and thus into
38           system-update.target. This target pulls in all system update units.
39           Only one service should perform an update (see the next point), and
40           all the other ones should exit cleanly with a "success" return code
41           and without doing anything. Update services should be ordered after
42           sysinit.target so that the update starts after all file systems
43           have been mounted.
44
45        5. As the first step, an update service should check if the
46           /system-update or /etc/system-update symlink points to the location
47           used by that update service. In case it does not exist or points to
48           a different location, the service must exit without error. It is
49           possible for multiple update services to be installed, and for
50           multiple update services to be launched in parallel, and only the
51           one that corresponds to the tool that created the symlink before
52           reboot should perform any actions. It is unsafe to run multiple
53           updates in parallel.
54
55        6. The update service should now do its job. If applicable and
56           possible, it should create a file system snapshot, then install all
57           packages. After completion (regardless whether the update succeeded
58           or failed) the machine must be rebooted, for example by calling
59           systemctl reboot. In addition, on failure the script should revert
60           to the old file system snapshot (without the symlink).
61
62        7. The update scripts should exit only after the update is finished.
63           It is expected that the service which performs the update will
64           cause the machine to reboot after it is done. If the
65           system-update.target is successfully reached, i.e. all update
66           services have run, and the /system-update or /etc/system-update
67           symlink still exists, it will be removed and the machine rebooted
68           as a safety measure.
69
70        8. After a reboot, now that the /system-update and /etc/system-update
71           symlink is gone, the generator won't redirect default.target
72           anymore and the system now boots into the default target again.
73

RECOMMENDATIONS

75        1. To make things a bit more robust we recommend hooking the update
76           script into system-update.target via a .wants/ symlink in the
77           distribution package, rather than depending on systemctl enable in
78           the postinst scriptlets of your package. More specifically, for
79           your update script create a .service file, without [Install]
80           section, and then add a symlink like
81           /usr/lib/systemd/system/system-update.target.wants/foobar.service →
82           ../foobar.service to your package.
83
84        2. Make sure to remove the /system-update and /etc/system-update
85           symlinks as early as possible in the update script to avoid reboot
86           loops in case the update fails.
87
88        3. Use FailureAction=reboot in the service file for your update script
89           to ensure that a reboot is automatically triggered if the update
90           fails.  FailureAction= makes sure that the specified unit is
91           activated if your script exits uncleanly (by non-zero error code,
92           or signal/coredump). If your script succeeds you should trigger the
93           reboot in your own code, for example by invoking logind's Reboot()
94           call or calling systemctl reboot. See org.freedesktop.login1(5) for
95           details about the logind D-Bus API.
96
97        4. The update service should declare DefaultDependencies=no,
98           Requires=sysinit.target, After=sysinit.target,
99           After=system-update-pre.target, Before=system-update.target and
100           explicitly pull in any other services it requires.
101
102        5. It may be desirable to always run an auxiliary unit when booting
103           into offline-updates mode, which itself does not install updates.
104           To do this create a .service file with
105           Wants=system-update-pre.target and Before=system-update-pre.target
106           and add a symlink to that file under
107           /usr/lib/systemd/system-update.target.wants .
108

SEE ALSO

110       systemd(1), systemd.generator(7), systemd-system-update-generator(8),
111       dnf.plugin.system-upgrade(8)
112

NOTES

114        1. GNOME design whiteboard
115           https://wiki.gnome.org/Design/OS/SoftwareUpdates
116
117
118
119systemd 254                                         SYSTEMD.OFFLINE-UPDATES(7)
Impressum