The automatic NFS mount at boot doesn't work. This is my fstab row:
nas:/backups /mnt/nas_backups nfs rw,_netdev,auto 0 0
Using mount -a
it works, but at boot it doesn't work. After some investigations, I think the problem lies in /etc/network/run/ifstate
: I say this because /etc/init.d/mountnfs.sh
calls /etc/network/if-up.d/mountnfs
, which contains this code:
exit_unless_last_interface() {
grep "^[:space:]*auto" /etc/network/interfaces | \
sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g' | \
while read i; do
if [ `grep -c $i /etc/network/run/ifstate` -eq "0" ]; then
msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
log_warning_msg "$msg"
# Can not pass this as a variable because of the while subshell
mkdir /var/run/network/mountnfs_earlyexit 2> /dev/null
fi
done
if [ -d /var/run/network/mountnfs_earlyexit ]; then
rmdir /var/run/network/mountnfs_earlyexit 2>/dev/null
exit 0
fi
}
This code makes the script exit, because in /etc/network/run/ifstate
there is not the eth0 interface (its only content is lo=lo
), although eth0 interface is up and running.
Do you have some suggestions about the causes ifstate is not correct, and how to resolve this?
UPDATE 1: This is the configuration of eth0
(an user said it could take a part in the problem, so I write it):
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
# The primary network interface
auto eth0
iface eth0 inet static
address 10.0.0.11
netmask 255.255.255.0
post-up iptables-restore < /etc/iptables.up.rules
gateway 10.0.0.1
UPDATE 2: This is the output of /etc/init.d/networking restart
:
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning).
Reconfiguring network interfaces...SIOCADDRT: File exists
Failed to bring up eth0.
done.
After the restart eth0
works correctly, and /etc/network/run/ifstate
still doesn't contain eth0
.
bash -x /etc/network/if-up.d/mountnfs
... done, this is the result: pastebin.com/jdSHrCdM PS I didn't know this bash option :)