Best Way To Mount A Directory on Boot
Basically I have a Navidrome container and it’s pointing at my music in a network mounted folder, what’s the best way to ensure that it’s always there, even after a reboot of my Pi?
Basically I have a Navidrome container and it’s pointing at my music in a network mounted folder, what’s the best way to ensure that it’s always there, even after a reboot of my Pi?
tvcvt, 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.
SeeJayEmm, 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.
phoenixnap.com/kb/nfs-docker-volumes
This is how I’m handling NFS mounts in my docker stacks.
vext01, Call me old fashioned, but fstab…
zaphod, (edited ) Assuming systemd, create a file like
<span style="color:#323232;">/etc/systemd/system/dir-to-mount.mount </span>
And then configure it per the systemd docs:
www.freedesktop.org/…/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.
sabreW4K3, Is this method superior to fstab?
zaphod, (edited ) 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 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.
Atemu, I’ll let you in on a little secret: Fstab gets converted to mount units anyways.
surewhynotlem, 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?
sabreW4K3, Navidrome to not run would be optimal
surewhynotlem, It’s probably best to wrap navidrome in a script that checks for the mount then.
sabreW4K3, Thanks for the advice, I’ll look into it.
null, Add it to your fstab
Add comment