fstab settings for nfs volume mount

Issues related to hardware problems
Post Reply
mirkoj
Posts: 33
Joined: 2010/02/01 04:49:19

fstab settings for nfs volume mount

Post by mirkoj » 2019/03/13 12:40:44

Hi,
I've got Synology NAS and NFS permission setup, all working perfectly fine.
Only thing I have an issue now is that volumes are not mounted at system startup.
I have to go and sudo mount -a after every reboot. After that evreything works perfectly fine.
Any idea what is going on?
A friend suggested it could be network issue like network still not fully up so is there a way to postpone mount for couple seconds?
Hre is what I have in fstab at the moment:

<IP>:/volume1/P /media/Storage/P nfs rsize=8192,wsize=8192,timeo=14,intr
<IP>:/volume1/Work /media/Storage/Work nfs rsize=8192,wsize=8192,timeo=14,intr
<IP>:/volume1/homes /media/Storage/homes nfs rsize=8192,wsize=8192,timeo=14,intr
<IP>:/volume1/D /media/Storage/D nfs rsize=8192,wsize=8192,timeo=14,intr

Thanks

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: fstab settings for nfs volume mount

Post by TrevorH » 2019/03/13 13:11:51

Set it up using autofs instead of fstab.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

larwood
Posts: 66
Joined: 2011/07/27 12:07:30
Location: Perth WA, Australia

Re: fstab settings for nfs volume mount

Post by larwood » 2019/03/14 06:42:15

You will need to add _netdev to your mount options.

As you are using CentOS 7 a better method would be to use systemd. I have an example posted here for CIFS that you could modify for NFS.

mirkoj
Posts: 33
Joined: 2010/02/01 04:49:19

Re: fstab settings for nfs volume mount

Post by mirkoj » 2019/03/14 07:37:23

Tried both options.
Followed guide for autonfs, everything is there but the mount doesn't happen at all.
Tried with _netdev option too as a friend suggested but also no luck.
Weird is that on another home machine when I tested centos it worked perfectly fine.
Also, mint testing went fine and automounting with identical fstab settings.
Only this comp is not doing it.
Considering reinstall and see what happens... ;)

lightman47
Posts: 1521
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: fstab settings for nfs volume mount

Post by lightman47 » 2019/03/14 11:27:01

Is there an error message produced? Also, having done it several times, do your /media/storage/* folders exist? ;)

mirkoj
Posts: 33
Joined: 2010/02/01 04:49:19

Re: fstab settings for nfs volume mount

Post by mirkoj » 2019/03/14 11:56:53

hehe yes they are there, it all works perfectly fine when I have fstab entry and do sudo mount -a :)
no error, just mounting is not happening until I do it manually.
but as I said I will proably do fresh reinstall of Centos and see what happens jstuj to wrap up some work I have. Interested to see if it will work then

lightman47
Posts: 1521
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: fstab settings for nfs volume mount

Post by lightman47 » 2019/03/14 12:12:42

couple more thoughts before the 'extreme' -

Is nfs-utils installed. I don't know if it matters, but it's installed here; also doesn't account for it working from the command line.

I've skipped clean re-installs in the past by rebooting to an older kernel, running yum reinstall *.*, then rebooting into the current kernel. This especially helped when I'd clobbered permissions somehow.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: fstab settings for nfs volume mount

Post by jlehtone » 2019/03/14 12:13:39

RHEL recommends to add the systemd automounts into the /etc/fstab:

Code: Select all

<IP>:/volume1/P  /media/Storage/P  nfs  defaults,noauto,nofail,x-systemd.automount 0 0
The systemd will create a unit at boot. If you edit the fstab entry further, then you have to make systemd reload or reboot in order to enable the changes.

The config above will mount the volume automatically the first time you access /media/Storage/P.

This will mount during boot whether you ever use it or not:

Code: Select all

<IP>:/volume1/P  /media/Storage/P  nfs  _netdev,defaults,nofail 0 0
_netdev The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).
Note:
intr / nointr This option is provided for backward compatibility. It is ignored after kernel 2.6.25.

If you yum install autofs
The /etc/auto.master contains

Code: Select all

# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
Thus, you coould write an .autofs file:

Code: Select all

# cat /etc/auto.master.d/local.autofs
/media/Storage  /etc/auto.master.d/auto.net
and the map file:
# cat /etc/auto.master.d/auto.net

Code: Select all

P     -fstype=nfs,hard,nodev,nosuid  <IP>:/volume1/P
Work  -fstype=nfs,hard,nodev,nosuid  <IP>:/volume1/Work
and then

Code: Select all

systemctl enable autofs
systemctl start autofs
The "cool" thing about autofs is that unused volumes unmount (and remount when you need them again).

You probably want in /etc/autofs.conf:

Code: Select all

browse_mode = yes
(The autofs default is 'yes', but the default config in CentOS has 'no'.)

Post Reply