Add it to your fstab
Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
Assuming systemd, create a file like
/etc/systemd/system/dir-to-mount.mount
And then configure it per the systemd docs:
https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html
Then modify the docker unit file to have a dependency on the mount unit so it's guaranteed to be up before docker starts.
Is this method superior to fstab?
It has the benefit that the container can't start before the mount point is up without any additional scripts or kludges, so no race conditions or surprise behaviour. Using fstab alone can't provide that guarantee. The other option is Autofs but it's messier to configure and may not ship out of the box on modern distros.
I'll let you in on a little secret: Fstab gets converted to mount units anyways.
fstab will do it, but the more important question is, what do you want to happen when it doesn't mount properly? Do you want the system to fail to boot? Do you want navidrome to not run?
Navidrome to not run would be optimal
It's probably best to wrap navidrome in a script that checks for the mount then.
Thanks for the advice, I'll look into it.
Everyone's saying fstab but if Navidrome is in a docker container, just mount it as a volume on your container. I found this guide that seems to document it fairly well.
https://phoenixnap.com/kb/nfs-docker-volumes
This is how I'm handling NFS mounts in my docker stacks.
So this is my preferred method, but I found the blog post really confusing. Subsequently, it failed.
navidrome:
container_name: navidrome
image: deluan/navidrome:latest
ports:
- "4533:4533"
environment:
ND_SCANSCHEDULE: 1h
ND_LOGLEVEL: info
volumes:
- "/opt/navidrome/data:/data"
- "/nfs/Shared Music:/music:ro"
- type: volume
- source: nfs
- target: /nfs
- volume:
nocopy: true
volumes:
nfs:
driver: local
driver_opts:
type: nfs
o: "addr=XXX.XXX.XXX.XXX,nolock,soft,rw"
device: ":/mnt/HD/Public"
What am I doing wrong?
I'm rather confused by the config you posted. The NFS config should all be down in the volumes: section the only thing you reference in the service section is the name of the volume you define and the path to mount in the container. Something like this (tho I'm guessing as to what should be what with your setup).
services:
navidrome:
container_name: navidrome
image: deluan/navidrome:latest
ports:
- "4533:4533"
environment:
ND_SCANSCHEDULE: 1h
ND_LOGLEVEL: info
volumes:
- /opt/navidrome/data:/data
- music:/music
volumes:
music:
driver_opts:
type: nfs
o: "addr=XXX.XXX.XXX.XXX,nolock,soft,ro"
device: ":/nfs/Shared Music"
Thank you so much.
One more question, do I have to point it directly at the directory I want or can I point it at one above? Reason being, I have a film directory which I will point Jellyfin to too.
You can point it to any nfs file system you have exported on the file server. That's entirely up to you.
Thank you
Call me old fashioned, but fstab...
It sounds like you’ve got your solution already, but just in case someone stumbles on this later, I thought I’d mention autofs.
I’m coming to prefer it over fstab entries because it handles disconnections nicely and attempts to reconnect. Worth checking out for those who haven’t played with it.