NFS mount in fstab won't mount on startup

Issues related to configuring your network
Post Reply
npolite
Posts: 29
Joined: 2007/11/30 03:35:01
Contact:

NFS mount in fstab won't mount on startup

Post by npolite » 2016/03/02 21:19:13

Hi All,

I've been using the same configuration for CentOS 5 and 6 where I have to NFS shares that mount on startup in /etc/fstab. I've placed this same configuration in CentOS 7.2 and the first of the two mounts does not mount properly. If I change the first entry to the IP address it mounts without any issues.


server.company.com:/nfs01/nfshome /nfshome nfs defaults,intr 0 0
server.company.com:/nfs01/shared /mnt/hlmon01/shared nfs defaults,intr 0 0

Here is what I see in the logs:

Mar 2 15:53:43 rc.local: mount.nfs: Failed to resolve server server.company.com: Temporary failure in name resolution
Mar 2 15:53:43 mount: mount.nfs: Failed to resolve server server.company.com: Temporary failure in name resolution
Mar 2 15:53:43 systemd: mnt-server-shared.mount mount process exited, code=exited status=32
Mar 2 15:53:43 systemd: Failed to mount /mnt/hlmon01/shared.
Mar 2 15:53:43 systemd: Unit mnt-server-shared.mount entered failed state.

I've disabled NetworkManager as some older posts suggested that was the cause of the issue but it still hasn't helped. Any suggestions would be appreciated.

Nick

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

Re: NFS mount in fstab won't mount on startup

Post by TrevorH » 2016/03/02 21:31:28

Personally I'd not use fstab for this. I'd use either autofs or I'd use a systemd mount unit file. For the latter you create a file in /etc/systemd/system/ called something.mount that looks something like this:

Code: Select all

[Unit]
Description=nfs mount script
Requires=network-online.service
After=network-online.service
Before=anything-dependent-on-this-mount.service

[Mount]
What=server.company.com:/nfs01/nfshome
# Where we want mount this share
Where=/nfshome
Options=
Type=nfs

[Install]
WantedBy=multi-user.target

# Important:
# this file must be renamed to <mountpoint>.mount where <mountpoint>, is the FULL path
# where the share will be mounted but slashes "/" MUST BE REPLACED with dashes "-" with .mount
# as extension.
# This means, if we want mount to "/storage/movies2" (see above "Where=/storage/movies2")
# then this file must be renamed to 'storage-movies2.mount' and can be enabled via ssh with the
# command 'servicectl enable storage-movies2.mount'
Since I stole this config file from my openelec/xbmc box, I am not sure if the naming convention for the file that they talk about in the comments above are xbmc requirements or whether they are systemd itself. You'll need to amend the Before= line to name a service that depends on this mount (or remove it altogether).
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

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: NFS mount in fstab won't mount on startup

Post by aks » 2016/03/03 17:19:07

A DNS issue perhaps? Or as Trevor suggests the network may not yet be online?

For DNS, try putting a static entry in /etc/hosts and see if that resolves the issue.

npolite
Posts: 29
Joined: 2007/11/30 03:35:01
Contact:

Re: NFS mount in fstab won't mount on startup

Post by npolite » 2016/03/08 12:34:46

HI aks,

I don't think the DNS is up at the time for the first NFS mount. The two entries I have are both mounts from the same server. As one mounts the other doesn't. I am going to try systemd to see if that helps.

Nick

npolite
Posts: 29
Joined: 2007/11/30 03:35:01
Contact:

Re: NFS mount in fstab won't mount on startup

Post by npolite » 2016/03/08 18:46:42

Hi All,

I tried to create the systemd file but it isn't working

[Unit]
Description=NFSHOME mount for hlmon01 Directory
Requires=network.target

[Unit]
Description=NFSHOME mount
Requires=network.target

[Mount]
What=server.company.com:/nfs01/nfshome
Where=/nfshome
Type=nfs
Options=

# Make 'systemctl enable tmp.mount' work:
[Install]
WantedBy=multi-user.target


I also tried the network-online.service but that also didn't work.

Any help would be appreciated. It seems to be an issue more with how quickly DNS starts working as using the IP address mounts without any issues.

Nick
~

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

Re: NFS mount in fstab won't mount on startup

Post by TrevorH » 2016/03/08 19:13:16

So you created that file and then did systemctl enable nfs-home.mount and systemctl start nfs-home.mount (or whatever you called the file)?
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

npolite
Posts: 29
Joined: 2007/11/30 03:35:01
Contact:

Re: NFS mount in fstab won't mount on startup

Post by npolite » 2016/03/09 12:59:08

Yep that is correct. Here are the sym links in /etc/systemd/system/multi-user.target.wants




lrwxrwxrwx 1 root root 44 Mar 8 08:36 mnt-hlmon01-shared.mount -> /etc/systemd/system/mnt-hlmon01-shared.mount
lrwxrwxrwx 1 root root 33 Mar 8 08:36 nfshome.mount -> /etc/systemd/system/nfshome.mount

Post Reply