Zygo / bees

Best-Effort Extent-Same, a btrfs dedupe agent
GNU General Public License v3.0
692 stars 56 forks source link

[Feature Request] Unmount mount points if beesd exits. #278

Open techno156 opened 8 months ago

techno156 commented 8 months ago

Issue Description

When run manually, beesd will create a new mount point for the drive, but will not clean it up on exit. This means that if a user is running bees on an external drive using the beesd script, they have to manually unmount the additional mountpoints before they can safely remove the drive.

This issue only applies if the user runs beesd manually, as the systemd service uses a private mount, and will clean up those mount points when stopped.

Suggestion and Implementation

Instead of leaving it up to the user, if the beesd script is terminated either by receiving SIGTERM or Interrupt/CTRL-C, the mountpoints created by the script should also be unmounted when exiting.

Issues with Implementation

One issue that I could see with doing it this way if the script tries to unmount a drive before it finishes flushing to the buffer, where it might just throw an error.

Another would be that the mountpoint would be left in cases where the script is killed, but that would be unavoidable.

Alternatives

According to https://github.com/Zygo/bees/issues/267#issuecomment-1737033636, users can also just use bees through systemd instead of the beesd helper script to avoid this issue.

Leaving users to unmount the points manually is also an option. All the mounts that beesd creates (such as after multiple runs) all share the same path, and can be unmounted simultaneously. Similarly, the user can unmount them all by unmounting the device that the path points to.