AutoNFS script (mounting NFS share without autofs )

First, since this is my first post Hello everyone :slight_smile:
I use openSUSE for years and this forum has on several occasions been of great help, thank you all for your great work.

As you probably know autofs does not offer an adequate solution for connecting to and mounting NFS shares. The problem with autofs is unmounting of inaccessible NFS share. When the server shuts down or we lose connection to it dolphin freezes and the whole system becomes unresponsive. Even worse if you try to turn off opensuse system when the NFS server is gone (turned off or disconnected) opensuse will stuck in some kind of loop and will never shut down…
Luckily I found a solution in the form of script:
The script is, however, written for the Ubuntu platform. Can someone please modify the installation procedure of the script in the init.d folder so that openSUSE 13.1 users can use it too.

To be more precise, the above script works, I tried it. I just do not want to start it manually each time. I want to start it automatically at boot time prior to login (after initializing the filesystem). As it is explained on the provided link, this is how it works in ubuntu world:

Installing a custom upstart job

The next step is to have the clients automatically run the above script when they are booted. We can use upstart for this. Create a new text file, and enter the following:

autonfs - mount NFS shares on fileserver, if present

description “Mount NFS-shares”

start on (filesystem)

exec /usr/local/bin/

This upstart job starts our script as soon as the filesystem is up, and restarts it (respawn) if it got killed. Save it as autonfs.conf. From a terminal (cd to the location of this new file), move it into place (it goes in /etc/init), and adjust the read/write permissions. We will also create a link in the /etc/init.d directory; this way, the upstart job can be treated like a normal init.d job (the SysVInit standard):

sudo chown root:root autonfs.conf
sudo chmod 644 autonfs.conf
sudo mv autonfs.conf /etc/init
cd /etc/init.d

sudo ln -s /lib/init/upstart-job autonfs

The script can now be started and stopped as a normal upstart job by calling start autonfs and stop autonfs.
Start the upstart job. When you reboot it will be started for you:

start autonfs

If you have more clients you want to set up in this way, repeat the above for them as well.

Apparently in opensuse world this does not work this way. Therefore, i need someone to translate these steps into the suse world.
What is the proper way to do it in opensuse 13.1?

I do not get all of this, but when you want a daemon to be started at boot, you should look into how systemd functions.

Thanks for the reply. I already know that it has to do with the systemd, but do not have a time to learn all depths and abysses of sisetemd and initialization in opensuse, just to do such a simple thing as a startup script at boot time. That’s why I’m asking here for a complete solution. Someone that already knows all about it, can probably do it in a few minutes.
Btw, is there any other way to auto mount/unmount “volatile” NFS share? With volatile i mean that i can not control when the server is up or down.

I have no doubt there are people here that can give you a more detailed description on how to create a systemd action for your purpose. Apparently none of them saw your thread. Maybe you can try a new one that has something like “How to make a systemd entry for …”, to draw the attention of a systemd guru.

For my own purposes I do have a script that runs on the client and that mounts an NFS when the server is available (crontab, every minute). That is easy enough (and I can show it to you when you want). But I did not solve the unmounting. Mainly because until 13.1 there was no need for it. IMHO the hanging of the client system is due to some bug and I still hope that a patch will emerge some time.

If no one replay with concrete solution I’ll sart a new thread or try to figure it out.

Cron job is another solution, you can probably try to add another task that will ping the server every minute and if there is no response unmount share.

Pity that dolphin does not support nfs as samba. With dolphin we can easily access samba server with a few clicks, and without taking into account how and where is remote file system mounted and without fear that it will crash the system if the server becomes unavailable. This is strange if you take into account that nfs is actually default linux sharing system not the samba.

To launch your script via systemd, create a unit file (eg /etc/systemd/system/autonfs.service) like this

Description=mount NFS shares on fileserver, if present



Then enable it

systemctl enable  autonfs.service

and start it

systemctl start autonfs.service

A few remarks.

First, hurray, someone with systemd knowldege is tuning in!

Then I am not sure it is Dolphin. The problem must be in the system, not in an end-user program like Dolphin. The fact that the client system here hangs even with no Dolphin running at the moment of the server going down supports this. Also, as said, this was not the case in earlier openSUSE versions, thus it must be some bug.

As a consuquence, I am not sure that simply trying to unmount from the client will help. But I can give that a try/test. Whne that is true, I will simply expand my mount cron run with such a function.

It works! I can even controll it through yast service manager. Thanks a lot.

I tried to say that dolphin has the ability to search for and mount local samba shares on demand (Places->Network->Samba Shares) without any script, configuration or setup by user. It just works with no problems. Ther is no such a thing for NFS.
I have had similar problems in earlier versions of opensuse with NFS+autofs combination.It is not suse problem but autofs, and it’s happening on all ather distros too. But you are not using autofs so I guess there must be some further issue with current release of opensuse…
Anyway this script: in combinations with deano_ferrari installation procedure offers decent solution. No more crashes of client system when server is down :slight_smile:

Also it seems that a simple command: umount -f -l /mnt/NFS works even when the server is unavailable. If you execute it before you try to access inaccessible share everything is going to be fine (no hangs).

that would then make it very simple.

Check if mounted
then    if server down
        then umount -f -l ...
else    if server up
        then mount

Run every minute by cron. I will test this (tomorrow or so)).


ive seen that some of you use AutoNFS as well. I use it (and developed it for a long time now) in my company in larger scale and have seen that there was lack of support for Systemd init system. Ive added support today! And my current version also supports a lot of other things and is more advanced than the version youve linked in this thread.

Heres mine:

If you have any bugs or enhancements or just things you want to see please file an issue. Since we use it in production as well, ill continue developing it.

Hope this helps :wink:

Its the most advanced AutoNFS version you can find on the internet :wink: