mirror of
https://github.com/nix-community/impermanence
synced 2024-11-10 13:54:18 +00:00
home-manager: Make unmounts more robust
Try to unmount normally a few times, and if that fails, unmount lazily to at least clean up the mount point before the fuse process is killed.
This commit is contained in:
parent
5b3345400c
commit
4d2cfadbc1
1 changed files with 28 additions and 2 deletions
|
@ -86,7 +86,20 @@ in
|
|||
fi
|
||||
'';
|
||||
stopScript = pkgs.writeShellScript "unmount-${name}" ''
|
||||
fusermount -uz "${mountPoint}"
|
||||
triesLeft=6
|
||||
while (( triesLeft > 0 )); do
|
||||
if fusermount -u "${mountPoint}"; then
|
||||
exit 0
|
||||
else
|
||||
(( triesLeft-- ))
|
||||
if (( triesLeft == 0 )); then
|
||||
echo "Couldn't perform regular unmount of ${mountPoint}. Attempting lazy unmount."
|
||||
fusermount -uz "${mountPoint}"
|
||||
else
|
||||
sleep 5
|
||||
fi
|
||||
fi
|
||||
done
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
@ -173,7 +186,20 @@ in
|
|||
in
|
||||
''
|
||||
if [[ -n ''${mountedPaths["${mountPoint}"]+x} ]]; then
|
||||
fusermount -u "${mountPoint}"
|
||||
triesLeft=3
|
||||
while (( triesLeft > 0 )); do
|
||||
if fusermount -u "${mountPoint}"; then
|
||||
break
|
||||
else
|
||||
(( triesLeft-- ))
|
||||
if (( triesLeft == 0 )); then
|
||||
echo "Couldn't perform regular unmount of ${mountPoint}. Attempting lazy unmount."
|
||||
fusermount -uz "${mountPoint}" || true
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue