Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: AutoNFS script (mounting NFS share without autofs )

  1. #1

    Default AutoNFS script (mounting NFS share without autofs )

    First, since this is my first post Hello everyone
    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:
    https://help.ubuntu.com/community/Au...outAutofsHowto
    or: https://github.com/vwal/nfs_automount

    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.

  2. #2

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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:
    Code:
    # autonfs - mount NFS shares on fileserver, if present
    
    description     "Mount NFS-shares"
    
    start on (filesystem)
    respawn
    
    exec /usr/local/bin/autonfs.sh
    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):
    Code:
    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:
    Code:
    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?

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,822

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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.
    Henk van Velden

  4. #4

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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.

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,822

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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.
    Henk van Velden

  6. #6

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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.

  7. #7
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,710
    Blog Entries
    1

    Default Re: AutoNFS script (mounting NFS share without autofs )

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

    Code:
    [Unit]
    Description=mount NFS shares on fileserver, if present
    After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/autonfs
    
    [Install]
    WantedBy=multi-user.target
    Then enable it
    Code:
    systemctl enable  autonfs.service
    and start it
    Code:
    systemctl start autonfs.service
    Last edited by deano_ferrari; 21-Feb-2014 at 22:15.

  8. #8
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,822

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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.
    Henk van Velden

  9. #9

    Default Re: AutoNFS script (mounting NFS share without autofs )

    Quote Originally Posted by deano_ferrari View Post
    To launch your script via systemd, create a unit file (eg /etc/systemd/system/autonfs.service) like this

    Code:
    [Unit]
    Description=mount NFS shares on fileserver, if present
    After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/autonfs
    
    [Install]
    WantedBy=multi-user.target
    Then enable it
    Code:
    systemctl enable  autonfs.service
    and start it
    Code:
    systemctl start autonfs.service
    It works! I can even controll it through yast service manager. Thanks a lot.

    Quote Originally Posted by hcvv View Post
    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.
    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:https://github.com/vwal/nfs_automount in combinations with deano_ferrari installation procedure offers decent solution. No more crashes of client system when server is down

  10. #10

    Default Re: AutoNFS script (mounting NFS share without autofs )

    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).

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •