diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-09 12:46:12 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-09 12:46:12 +0200 |
commit | d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690 (patch) | |
tree | e560d5c1461720efdfca73535fd4766ef4ceb188 /custom | |
parent | 0a4d21fd755b360314f46ffeb81c1d32dec00c59 (diff) | |
download | nixos-d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690.tar nixos-d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690.tar.gz nixos-d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690.tar.bz2 nixos-d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690.tar.xz nixos-d0d4b4fb16bea89fe1382d4fd792c1e1a6a24690.zip |
…
Diffstat (limited to 'custom')
-rw-r--r-- | custom/lvm-snapshots.nix | 16 |
1 files changed, 13 insertions, 3 deletions
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 { | |||
68 | systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + snapshotName name) { | 68 | systemd.services = mapAttrs' (name: scfg: nameValuePair ("lvm-snapshot@" + snapshotName name) { |
69 | enable = true; | 69 | enable = true; |
70 | 70 | ||
71 | description = "LVM-snapshot of ${scfg.VG}/${scfg.LV}"; | ||
72 | |||
71 | unitConfig = { | 73 | unitConfig = { |
72 | StopWhenUnneeded = true; | 74 | StopWhenUnneeded = true; |
73 | }; | 75 | }; |
74 | 76 | ||
77 | path = with pkgs; [ devicemapper ]; | ||
78 | |||
79 | script = '' | ||
80 | lvcreate -s ${scfg.cowSize} --name ${snapshotName name} ${scfg.VG}/${scfg.LV} | ||
81 | ''; | ||
82 | |||
83 | preStop = '' | ||
84 | lvchange -a n ${scfg.VG}/${snapshotName name} | ||
85 | lvremove ${scfg.VG}/${snapshotName name} | ||
86 | ''; | ||
87 | |||
75 | serviceConfig = with pkgs; { | 88 | serviceConfig = with pkgs; { |
76 | Type = "oneshot"; | 89 | Type = "oneshot"; |
77 | ExecStart = "${devicemapper}/bin/lvcreate -s ${scfg.cowSize} --name ${snapshotName name} ${scfg.VG}/${scfg.LV}"; | ||
78 | ExecStopPre = "${devicemapper}/bin/lvchange -a n ${scfg.VG}/${snapshotName name}"; | ||
79 | ExecStop = "${devicemapper}/bin/lvremove ${scfg.VG}/${snapshotName name}"; | ||
80 | RemainAfterExit = true; | 90 | RemainAfterExit = true; |
81 | }; | 91 | }; |
82 | }) cfg.snapshots; | 92 | }) cfg.snapshots; |