Flatpak and snap becomes more and more popular. One of the reasons is that it is possible to do sandboxing. Which may give issues, if you need access to something outside the sandbox.
I have a nextcloud server running in snap, and it works great. However my OS and apps runs in a relative small SSD disk, so there isn’t much storage in my cloud. I have a couple of 3 TByte disks in the same server, and would like that to hold my cloud storage.
The documentation on how to add external storage to the Nextcloud was not good, or I was to sleepy, so I was investigating how to circumvent the snap sandbox.
Tada – bind mount came to my rescue.
For testing you can do the mount directly from the CLI:
$sudo mount –bind <Source directory> <Mount point>
And after verifying that it works, you want to change your fstab:
<source directory> <mount point> none defaults,bind 0 0
The mount point should be inside your snap sandbox e.g. /var/snap/nextcloud/common/nextcloud/data
In the good old days it was possible to hard link directories, but modern linux’es seems to have abandoned the philosophy “If you want to shoot yourself in the foot – go ahead and do so”, so it is no longer possible to do this.
But there you can use the bind mount.
Just installed the jellyfin media server, and my music collection is buried below my nextcloud files.
But since the jellyfin runs as another user, it cannot see anything within my home directory:
I made a directory: /media/Music and made a bind mount:
$sudo mount –bind /home/myuser/Nextcloud/Music /media/Music
And now the media server had access to all my music