0

I have a small embedded (mips) device which runs a very lightweight Linux.

It is capable of mounting NFS shares (manually by mount command).

However I want to mount it automatically, so I have defined it in the fstab file.

The problem is that the device does not have connection available at the time fstab is processed:

mount: mounting 10.1.1.1:/srv/fs on /nfs failed: Input/output error

Then the system continues to boot (initialize the wifi module, connects to AP, and queries the IP address with udhcpc.

After udhcpc successfully gets the IP address, I can run:

mount -a

and the /nfs will be mounted successfully.

How can I tell fstab to wait, and retry constantly?

Please note this is a truncated Linux. There is no systemd or ifup scripts available.

Of course, I can run a script on boot which runs 'mount -a' constantly until success, but that's the brute-force-way and I'm looking for something more sophisticated solution if it exists.

0

The usual solution is to make the DHCP client inform you after it has finished configuring the network. Most DHCP clients have the ability to start "hook" shellscripts for that purpose, and so does udhcpc. According to documentation,

When an event occurs, udhcpc calls the action script. The script by default is /usr/share/udhcpc/default.script but this can be changed via the command line arguments. The three possible arguments to the script are: [...]

bound: This argument is used when udhcpc moves from an unbound, to a bound state. All of the paramaters are set in enviromental variables, The script should configure the interface, and set any other relavent parameters (default gateway, dns server, etc).

This means you can just place a shellscript at the correct location (use the --script option if necessary), and make it start your mounts whenever it is called with $1 parameter set to bound.

#!/bin/sh
if [ "$1" = bound ]; then
    mount -a
fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.