summaryrefslogtreecommitdiff
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/lvm-snapshots.nix14
1 files changed, 10 insertions, 4 deletions
diff --git a/custom/lvm-snapshots.nix b/custom/lvm-snapshots.nix
index af8b61bb..afa5a9d6 100644
--- a/custom/lvm-snapshots.nix
+++ b/custom/lvm-snapshots.nix
@@ -71,12 +71,19 @@ in {
71 71
72 unitConfig = { 72 unitConfig = {
73 StopWhenUnneeded = !scfg.persist; 73 StopWhenUnneeded = !scfg.persist;
74 AssertPathIsDirectory = "/var/lock";
74 }; 75 };
75 76
76 path = with pkgs; [ devicemapper ]; 77 path = with pkgs; [ devicemapper utillinux ];
77 78
78 script = '' 79 script = ''
79 lvcreate -s ${scfg.cowSize} --name ${snapshotName name} ${scfg.VG}/${scfg.LV} 80 (
81 flock -xn 9 || exit 1
82
83 lvcreate -s ${scfg.cowSize} --name ${snapshotName name} ${scfg.VG}/${scfg.LV}
84
85 sleep infinity &
86 ) 9>/var/lock/lvm-snapshot.${scfg.VG}
80 ''; 87 '';
81 88
82 preStop = '' 89 preStop = ''
@@ -84,8 +91,7 @@ in {
84 ''; 91 '';
85 92
86 serviceConfig = with pkgs; { 93 serviceConfig = with pkgs; {
87 Type = "oneshot"; 94 Type = "forking";
88 RemainAfterExit = true;
89 }; 95 };
90 }) cfg.snapshots; 96 }) cfg.snapshots;
91 97