From d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 9 Apr 2018 12:46:12 +0200 Subject: =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom/lvm-snapshots.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'custom') diff --git a/custom/lvm-snapshots.nix b/custom/lvm-snapshots.nix index b6527a1f..34c10460 100644 --- a/custom/lvm-snapshots.nix +++ b/custom/lvm-snapshots.nix @@ -68,15 +68,25 @@ in { systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + snapshotName name) { enable = true; + description = "LVM-snapshot of ${scfg.VG}/${scfg.LV}"; + unitConfig = { StopWhenUnneeded = true; }; + path = with pkgs; [ devicemapper ]; + + script = '' + lvcreate -s ${scfg.cowSize} --name ${snapshotName name} ${scfg.VG}/${scfg.LV} + ''; + + preStop = '' + lvchange -a n ${scfg.VG}/${snapshotName name} + lvremove ${scfg.VG}/${snapshotName name} + ''; + serviceConfig = with pkgs; { Type = "oneshot"; - ExecStart = "${devicemapper}/bin/lvcreate -s ${scfg.cowSize} --name ${snapshotName name} ${scfg.VG}/${scfg.LV}"; - ExecStopPre = "${devicemapper}/bin/lvchange -a n ${scfg.VG}/${snapshotName name}"; - ExecStop = "${devicemapper}/bin/lvremove ${scfg.VG}/${snapshotName name}"; RemainAfterExit = true; }; }) cfg.snapshots; -- cgit v1.2.3