From c5915c636af13c65fbf1e9b686c7d6c4f51338ff Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 28 Jul 2015 08:16:11 -0400 Subject: man: import "Implementing Offline System Updates" This imports most of http://www.freedesktop.org/wiki/Software/systemd/SystemUpdates/ to turn it into a man page. Similarly for the man page about generators, this will make it easier to keep up-to-date, keep a history of changes, and make it more discoverable for end-users. --- man/systemd.offline-updates.xml | 151 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 man/systemd.offline-updates.xml (limited to 'man') diff --git a/man/systemd.offline-updates.xml b/man/systemd.offline-updates.xml new file mode 100644 index 0000000000..dd4fad853c --- /dev/null +++ b/man/systemd.offline-updates.xml @@ -0,0 +1,151 @@ + + + + + + + + systemd.offline-updates + systemd + + + + Developer + Lennart + Poettering + lennart@poettering.net + + + + + + systemd.offline-updates + 7 + + + + systemd.offline-updates + Implementation of offline updates in systemd + + + + Implementing Offline System Updates + + This is implemented starting with systemd 183. + + Here are some guidelines how to implement "offline" OS updates with systemd. By "offline" + OS updates we mean package installations and updates that are run with the system booted into a + special system update mode, in order to avoid problems related to conflicts of libraries and + services that are currently running with those on disk. This document is inspired by this + GNOME design whiteboard. + + + The logic: + + + + The package manager prepares system updates by downloading all (RPM or DEB or + whatever) packages to update off-line in a special directory + /var/lib/system-update (or + another directory of the package/upgrade manager's choice). + + + + When the user OK'ed the update, the symlink /system-update is + created that points to /var/lib/system-update + (or wherever the upgrade package directory is called) and the system is rebooted. This + symlink is in the root directory, since we need to check for it very early at boot, at a + time where /var is not available yet. + + + + Very early in the new boot a systemd generator checks whether + /system-update exists. If so, it (temporarily and for this boot only) + redirects (i.e. symlinks) default.target to + system-update.target, a new target that is intended to pull in the base + system (i.e. sysinit.target, so that all file systems are mounted but + little else) and the system update units. + + + + The system now continues to boot into default.target, and thus + into system-update.target. This target pulls in the OS update script, + which is executed after all file systems are mounted. + + + + The system update script now creates a btrfs snapshot (if possible), then installs all + RPMs. After completion (regardless whether the update succeeded or failed) the + /system-update symlink is removed. In addition, on failure it reverts to the old btrfs state + (modulo the aforementioned symlink), on success it leaves the newly made changes in + place. + + + + The system is rebooted. Since the /system-update symlink is gone, + the generator won't redirect default.target after reboot and the + system now boots into the default target again. + + + + + + Recommendations + + + + To make things a bit more robust we recommend hooking the update script into + system-update.target via a .wants/ + symlink in the distribution package, rather than depending on systemctl + enable in the postinst scriptlets of your package. More specifically, for your + update script create a .service file, without [Install] section, and then add a symlink like + /usr/lib/systemd/system-update.target.wants/foobar.service + → ../foobar.service to your package. + + + + Make sure to remove the /system-update symlink early in the + update script to avoid reboot loops in case the update fails. + + + + Use OnFailure=reboot.target in the service file for your update + script to ensure that a reboot is automatically triggered if the update fails. + OnFailure= makes sure that the specified unit is activated if your script + exits uncleanly (by non-zero error code, or signal/coredump). If your script succeeds you + should trigger the reboot in your own code, for example by invoking logind's + Reboot() call. See + logind dbus API + for details. + + + + + + See also + + + Implementing Offline System Updates, + systemd1, + systemd.generator7 + + + -- cgit v1.2.3-54-g00ecf