Nfs – fstab mount after network initialization

bootmountnfs

I'm automatically mounting a NFS with fstab. Sometimes the mount fails because the hostname of the NFS mount cannot be resolved (getaddrinfo failed). I'm assuming that this happens because the network initialization is slower than the mounts.

Is there any way to initialize the network before mounting any devices? I'm already using _netdev as a mount option but this does not help.

This is my current fstab file:

# <file system> <mount point>   <type>  <options>   <dump>  <pass>
/dev/md2    /   ext3    errors=remount-ro   0   1
/dev/md1    /boot   ext3    errors=remount-ro   0   1
/dev/sda3   swap    swap    defaults    0   0
/dev/sdb3   swap    swap    defaults    0   0
connect.mygluster.net:/data /var/gluster/data glusterfs ro,_netdev 0

Best Answer

IMO, I don't recommend modifying fstab to mount NFS folders. Instead, you can customize the startup script of the dependent service to mount the NFS folder before starting the service.

Another option is to create a new startup script under /etc/init.d to mount NFS folder. You can copy some of the already available services file and use it. You need to make sure it contains a line like:

# Required-Start:    $network other-stuff...