diff --git a/Makefile.am b/Makefile.am index 69cea75c1..d6729e5df 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3645,7 +3645,8 @@ systemgenerator_PROGRAMS += \ systemd-cryptsetup-generator dist_systemunit_DATA += \ - units/cryptsetup.target + units/cryptsetup.target \ + units/cryptsetup-pre.target systemd_cryptsetup_SOURCES = \ src/cryptsetup/cryptsetup.c diff --git a/man/systemd.special.xml b/man/systemd.special.xml index 38b94a765..4dd7d9701 100644 --- a/man/systemd.special.xml +++ b/man/systemd.special.xml @@ -52,6 +52,7 @@ bluetooth.target, ctrl-alt-del.target, cryptsetup.target, + cryptsetup-pre.target, dbus.service, dbus.socket, default.target, @@ -839,6 +840,27 @@ transaction. + + cryptsetup-pre.target + + This passive target unit + may be pulled in by services + that want to run before any + encrypted block device is set + up. All encrypted block + devices are set up after this + target has been reached. Since + the shutdown order is + implicitly the reverse + start-up order between units + this target is particularly + useful to ensure that a + service is shut down only + after all encrypted block + devices are fully + stopped. + + local-fs-pre.target diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 38c746b8b..8e44f3c25 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -123,7 +123,7 @@ static int create_disk( "DefaultDependencies=no\n" "BindsTo=dev-mapper-%i.device\n" "IgnoreOnIsolate=true\n" - "After=systemd-readahead-collect.service systemd-readahead-replay.service\n", + "After=systemd-readahead-collect.service systemd-readahead-replay.service cryptsetup-pre.target\n", f); if (!nofail) diff --git a/units/cryptsetup-pre.target b/units/cryptsetup-pre.target new file mode 100644 index 000000000..65353419f --- /dev/null +++ b/units/cryptsetup-pre.target @@ -0,0 +1,11 @@ +# This file is part of systemd. +# +# 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 +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Encrypted Volumes (Pre) +Documentation=man:systemd.special(7) +RefuseManualStart=yes