diff options
Diffstat (limited to 'custom/lvm-snapshots.nix')
-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; |