[SOLVED] zfs pool, mount --bind: Syncthing deleting files from dirs after unmount

Hi,

my setup is as follows:

  • ZFS pool /pool0
  • /pool0/Software/IrfanView is a “real-data” folder
  • /view/pool0 is a “real-data” folder
  • Pool is auto-mounted on startup

I intended to work around using Symlinks with mount --bind. I had no problems setting up the following bind mount: /view/pool0/IrfanView -> /pool0/Software/IrfanView . Done via shell, it lasts until I reboot the server.

My intention is to get a software repository up which could sync some “virtually visible” folder structures form the (big) main repository. To be clear: /pool0 are the “real files” and /view/pool0 should be the “virtual” view achieved by the bind mounts below that folder.

mkdir -p /view/pool0/IrfanView
mount --bind /pool0/sync/Install/IrfanView/ /view/pool0/IrfanView

image

After setting up, the contents of “IrfanView” appear correctly in the view:

Syncthing picks them up correctly:

image

Now I’m testing what happens on loosing the pool which underlies the mount --bind.

zpool export pool0

Syncthing announces everything as “deleted” to the other nodes. This is correct from Synchting’s perspective, but bad for me as everything has to be resynced later.

image

I’m now having this state on the /view/… folders.

image

image

Do you have any ideas for me how I could solve this. I’d wish Syncthing could detect this somehow but it seems difficult due to the nature of the mount point in /view/… which is an empty folder until anyone issues the “mount --bind” command after the pool re-mount again.

I thought about the .stfolder, perhaps I could mount --bind this too but it has the same drawback. Would it work for Syncthing’s code to allow .stfolder to be a symlink and then detecting the bad state of the “view folder” when the .stfolder symlink is dangling? Then I’d place .stfolder as a symlink to a dummy folder on the pool. Or is there a better way?

Sure, I could use scripting and systemd to try at least to ensure as max as possible the pool unmounts expectedly after a Syncthing service shutdown but in case of an error or apt-get dist-upgrade replacing the ZFS driver or delay in reboot I see my thing failing.

Regards, Catfriend1

Or, just thinking more over about it:

  • Can it use a sub-subfolder relative to the Syncthing folder root, e.g. /IrfanView/dummyfolder as a folder marker?

  • Any chance, I could use /IrfanView/dummyignore.txt as an include at /view/pool0/.stignore and the folder will stop in time when the included file goes unavailable?

Ideas welcome :slight_smile:

There is no safeguards for bind-mounts disappearing inside the directory tree.

You can override the marker name, so perhaps pointing it to some file in the directory would work, but in theory, your folder root should be an IfranView and not where it is now.

1 Like

I’ll try that, best would be if I could point the marker to a sub-subdir

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.