Problem Description:
I’m trying to create a large photo album on a website. Each theme is assigned a directory. In each directory are all the thumbnails for the theme. I also want to create a directory that links to another directory where the full-size photos are stored. For my own peace of mind, I want this to be a read only link.
I have tried creating a symbolic directory link. It works but I cannot make it read only.
I have tried a mount --bind using the following:
mount --bind /path/to/target /path/to/link
mount -o remount,ro,bind /path/to/link
Again, this works, it is read only but it doesn’t persist through a reboot.
I know I can add the details to /etc/fstab but that is going to be very tedious (and probably open to many errors).
Don’t know any easier way, but here’s an idea for a different way where errors might be less problematic: Can you use systemd mount units?
Since you seem to be indicating that you’ll need a lot of these read-only bind mounts, here is some bash code that might help you create a shell script based on the idea of implementing these read-only bind mounts with systemd mount units:
Of course replacing /path/to/target with the actual path to the “real” storage directory and /path/to/link with the actual path at which you want the read-only bind mount.
For more info about what this code snippet is doing, refer to the following man pages:
Have you looked into Nextcloud or Owncloud which can be set up on Ubuntu server and may have features already developed that accomplish what you want. Lots of security and network considerations to get in order if looking to put a server on the internet.
Can you not play with the permissions? Make sure the web server software can only read, then give user needing to manage the pictures read/write access?
Your ultimate goal is not clear to me. You are concerned about the webserver software possibly modifying the pictures?