Sharing pages between local logseq graphs using Syncthing on Linux
This post addresses how to keep two directories in sync on a single Linux machine using Syncthing (avoiding things like rsync, unison, etc.). This is particularly useful if you have two logseq graphs on your system and you want to share a directory underneath your pages
directory between both.
Setting up the mount
- Requirements:
- util-linux v2.39
- Preparation:
sudo useradd -m USERNAME_helper
- Make note of the user id and group id (usually they are the same number)
- Testing the mount one-time:
sudo mount --bind -oX-mount.idmap=b:1000:1001:1 /home/USERNAME/shared_logseq /home/USERNAME_helper/shared_logseq
- This assumes your main user has uid/gid 1000 and the helper account has uid/gid 1001
- If the target directory does not yet exist, create it first
- If this works correctly, you can unmount it and start setting up the permanent mount as follows
- Setting the mount permanently in
/etc/fstab
:/home/USERNAME/shared_logseq /home/USERNAME_helper/shared_logseq none defaults,user,bind,X-mount.idmap=b:1000:1001:1 0 0
- The
b
flag creates both user and group mapping - Mount the directory:
sudo mount /home/USERNAME_helper/shared_logseq
Setting up Syncthing
- Let systemd launch an extra syncthing permanently:
sudo systemctl enable --now syncthing@USERNAME_helper
- Check the logs and find the port number used by syncthing:
sudo systemctl status syncthing@USERNAME_helper
- Open the syncthing with a browser and configure it to disable NAT, global discovery and relays
- Connect your Syncthing instances together as usual, and share the folders between the syncthing instances