Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

System not automatically mounting NFS volumes at startup

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
alvitali
Posts: 3
Joined: 2024-04-05 02:01

System not automatically mounting NFS volumes at startup

#1 Post by alvitali »

Hi, this is my first proper Linux install, so I don't really know my way around the OS yet. Apologies in advance

I want to automatically mount two NFS volumes which reside on a different machine at boot, that contain persistent volumes for some of my docker containers. I've followed some guides I found online, and added the remote NFS directory to the /etc/fstab file, currently looking like this (I played around with the options trying to get it to work, mostly relying on https://help.ubuntu.com/community/Fstab#Options and a few forum posts):

Code: Select all

# external storage directory mount
10.8.0.15:/volume/storage	/home/docker/mount/storage	nfs	auto,rw,noexec,user,_netdev	0	0
However, I cannot seem to get the directories to automatically mount at startup. I can only mount them manually after the fact, e.g. with ```mount -a```. I've looked at several help requests / forum posts online, however most seem to have been caused by different issues (e.g. incorrect fstab entries). A few mention to check startup logs or similar logs to get to the root cause - however, most of these were Linux distributions other than Debian (and log directories seem to be one of the things which differ a lot between distros?).

One of the solutions mentioned often is to use autofs instead of specifying as fstab entries. I couldn't really discern whether that still holds up today: I try to stick to minimal solutions to avoid unnecessary complexity. I'd rather use the OS's features than installing an extra package; moreover, autofs seems to be built for a different use case - all I need is static volume mounts.

Desperate for a solution, I tried to execute a shell script at bootup to run ```mount -a```, but this didn't work either. I didn't investigate properly, and I'm not sure what permissions scripts executed by update-rc.d run with, maybe this was an issue... a lot of forum entries however speculated that network components not yet being available might be the cause for NFS volumes in fstab not mounting, which would then be true for the script as well?

Can anyone point me in the right direction regarding log files or other avenues I could investigate to resolve my issue? I'm desperate to get this working by now. For context, I'm running Debian bookworm in a minimal install.
Last edited by alvitali on 2024-04-05 08:05, edited 1 time in total.

peter_irich
Posts: 1406
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: System not mounting NFS volumes at startup

#2 Post by peter_irich »

Files an directories must be export on other computer, man exports.

peer
Posts: 459
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: System not mounting NFS volumes at startup

#3 Post by peer »

I have this line in my fstab:

Code: Select all

192.168.2.5:/volume1/data     /mnt/synology/data   nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0 
It mounts a directory on my synology nas to my main pc. Works ok.

mount line in terminal:

Code: Select all

sudo mount -t nfs 192.168.2.5:/volume1/data /mnt/synology/data
umount line in terminal:

Code: Select all

sudo umount 192.168.2.5:/volume1/data
And you have to configure your other computer with export see the following tutorial:
https://www.howtoforge.com/tutorial/ins ... -on-debian

alvitali
Posts: 3
Joined: 2024-04-05 02:01

Re: System not mounting NFS volumes at startup

#4 Post by alvitali »

Hi, thanks for your reply! Mounting manually works without a problem - my issue is, that the NFS directory doesn't mount automatically when starting up the server. Does that work for you?

I'm also connecting to a Synology box. Using the entries you provided (auto,nofail,noatime,nolock,intr,tcp,actimeo=1800) doesn't work either. I always have to mount the directories manually, or they won't mount.

peer
Posts: 459
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: System not automatically mounting NFS volumes at startup

#5 Post by peer »

The mount rule in fstab works ok. The synology maps are automatically mounted at boot..

Before I used fstab I used a script to mount the synology maps. I started that script automatically at boot (in debian kde) but I had to write a rule for the sudoers file to prevent asking for a password.

Aki
Global Moderator
Global Moderator
Posts: 3079
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 76 times
Been thanked: 416 times

Re: System not automatically mounting NFS volumes at startup

#6 Post by Aki »

@alvitali: what is your init system ? You can check with:

Code: Select all

ls -la /sbin/init
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

alvitali
Posts: 3
Joined: 2024-04-05 02:01

Re: System not automatically mounting NFS volumes at startup

#7 Post by alvitali »

@Aki This gives back systemd "/sbin/init -> /lib/systemd/systemd"

I still haven't got it to work. What's even more annoying now though, after turning off one of my NFS servers, I cannot mount that directory anymore. When I try to mount, umount etc. I always get "mount.nfs: Stale file handle". I realize this is expected behaviour, when connection is lost without unmounting - however it's irritating that this is the default (especially as, unlike for seemingly everyone else, I've got no way to ever mount the directory again because of that error, which survives restarting init.d/nfs AND rebooting the server?)

On a reddit thread on the topic, I've stumbled upon the recommendation to use systemd automount instead of autofs. I might give this a try if I can't get this to work any other way.

A hunch I've got just now - is it possible that fstab does not work because the mounted directory is not in /mnt/ but in my home directory instead?

CwF
Global Moderator
Global Moderator
Posts: 2741
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 45 times
Been thanked: 206 times

Re: System not automatically mounting NFS volumes at startup

#8 Post by CwF »

alvitali wrote: 2024-04-09 22:40 On a reddit thread on the topic, I've stumbled upon the recommendation to use systemd automount instead of autofs. I might give this a try if I can't get this to work any other way.

A hunch I've got just now - is it possible that fstab does not work because the mounted directory is not in /mnt/ but in my home directory instead?
Yes, and for mounts relevant to a particular user, put the systemd-mount command in ~/.profile.

Code: Select all

systemd-mount --discover --automount=yes --timeout-idle-sec=60 /dev/disk/by-label/noise ~/Music
--discover optional

Post Reply