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. --- Makefile-man.am | 2 + man/systemd.offline-updates.xml | 151 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 man/systemd.offline-updates.xml diff --git a/Makefile-man.am b/Makefile-man.am index a7e348b1f1..a4835a533f 100644 --- a/Makefile-man.am +++ b/Makefile-man.am @@ -144,6 +144,7 @@ MANPAGES += \ man/systemd.link.5 \ man/systemd.mount.5 \ man/systemd.nspawn.5 \ + man/systemd.offline-updates.7 \ man/systemd.path.5 \ man/systemd.preset.5 \ man/systemd.resource-control.5 \ @@ -2651,6 +2652,7 @@ EXTRA_DIST += \ man/systemd.netdev.xml \ man/systemd.network.xml \ man/systemd.nspawn.xml \ + man/systemd.offline-updates.xml \ man/systemd.path.xml \ man/systemd.preset.xml \ man/systemd.resource-control.xml \ 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 From 45f0c64e5f1bba0a6b9b5f4856431e870c431431 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 15 Mar 2016 21:59:11 -0400 Subject: man/offline-updates: more links and support for multiple upgrade services Most of the changes are already implemented in dnf-system-upgrade.service and packagekit-offline-update.service, so this update mostly changes the documentation to match status quo. --- man/systemd.offline-updates.xml | 72 +++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/man/systemd.offline-updates.xml b/man/systemd.offline-updates.xml index dd4fad853c..946234ad90 100644 --- a/man/systemd.offline-updates.xml +++ b/man/systemd.offline-updates.xml @@ -6,6 +6,7 @@ This file is part of systemd. Copyright 2013 Lennart Poettering + Copyright 2016 Zbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -49,9 +50,7 @@ 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" + This man page describes how to implement "offline" system 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 @@ -70,33 +69,45 @@ 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 + created that points to /var/lib/system-update (or + wherever the directory with the upgrade files is located) 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. + Very early in the new boot + systemd-update-generator8 + 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 special target that is pulls 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. + into system-update.target. This target pulls in the system update unit, + which starts the system update script after all file systems have been mounted. + + + + As the first step, the update script should check if the + /system-update symlink points to the the location used by that update + script. In case it does not exists or points to a different location, the script must exit + without error. It is possible for multiple update services to be installed, and for multiple + update scripts to be launched in parallel, and only the one that corresponds to the tool + that created the symlink before reboot should perform any actions. It + is unsafe to run multiple updates in parallel. - 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 update script should now do its job. If applicable and possible, it should + create a file system snapshot, then install all packages. + After completion (regardless whether the update succeeded or failed) the machine + must be rebooted, for example by calling systemctl reboot. + In addition, on failure the script should revert to the old file system snapshot + (without the symlink). @@ -122,20 +133,25 @@ - Make sure to remove the /system-update symlink early in the - update script to avoid reboot loops in case the update fails. + Make sure to remove the /system-update symlink as early as + possible 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 + Use FailureAction=reboot in the service file for your update script + to ensure that a reboot is automatically triggered if the update fails. + FailureAction= 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 or calling systemct reboot. See logind dbus API for details. + + + The update service should declare DefaultDependencies=false, + and pull in any services it requires explicitly. + @@ -145,7 +161,9 @@ Implementing Offline System Updates, systemd1, - systemd.generator7 + systemd.generator7, + systemd-update-generator8, + dnf.plugin.system-upgrade8 -- cgit v1.2.3-54-g00ecf