Announcement

Collapse
No announcement yet.

nfs Line in fstab Too Slow to Process When Server Is Off

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] nfs Line in fstab Too Slow to Process When Server Is Off

    I have a server that is not 24/7. I have my main computer that has an nfs entry in fstab to mount a server directory. From other posts, I've configured the fstab line so the nfs directory will load only when the server is available. I've tried to tweak the line further to reduce the time the system takes to process that nfs mount, but

    systemd-analyze blame still report over 1.5 minutes to process the nfs line even when the server is down.

    Code:
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda1 during installation
    UUID=6bb8b708-55bf-4acd-bf77-b7f70d60d41b /               ext4    errors=remount-ro             0   1
    #
    # This is the data drive mounted to /media/Data
    UUID=9d3f1ff1-99b4-418c-8dca-84916431f9d5 /media/Data     ext4    auto,exec,rw,noatime          0   2
    #
    # This is the server mount of /nas
    192.168.1.105:/nas                        /media/NAS       nfs  timeo=14,intr,auto,exec,rw,_netdev          0   0
    I need a good configuration of the options so the nfs directory mounts quickly when the server is running or doesn't mount it quickly when the server is not running. Searching for answers has led me to this Frankenstein configuration that does not work.
    Last edited by mhumm2; Dec 16, 2018, 09:23 AM.
    "If you're in a room with another person who sees the world exactly as you do, one of you is redundant." Dr. Steven Covey, The 7-Habits of Highly Effective People

    #2
    You might try setting retrans= and/or retry= to some numbers and see if that helps.

    However, if you know your server is off fairly often, why attempt to mount it this way at all? You could simply create a network connection to it in Dolphin and access it that way when you know it's available. Or add "users" or "user" along with "noauto" to your fstab line and then you can manually mount it after booting by entering "mount /media/NAS" in krunner (ALT-F2). If you want fancy, create a simple script that runs at boot that checks for the server (ping) and mounts it if it's there.

    Also, there are a plethora of mounting options for NFS. Try some of these that I use;

    nofail,x-systemd.automount,x-systemd-device-timeout=10,timeo=1,retrans=5,intr,noatime,nodirati me 0 0

    Please Read Me

    Comment


      #3
      We should both probably switch to using autofs

      Please Read Me

      Comment


        #4
        I think oshunluvr has pretty much covered the options, but here is my line in fstab for my NAS which is almost allways off. There is no 'hang' at all with these options as no attempt is made to mount it at boot. I think the key option you want is 'noauto'--

        Code:
        192.168.1.3:/mnt/HD/HD_a2	/media/DNS-320L/V1_Media	nfs	rw,hard,intr,noexec,noauto,user,retrans=1,retry=0
        It took me a while to tweak these options as there are so many of them. What drove me to do this is that I have the NAS in standby mode and doing something like just starting Dolphin, Gwenview or any open file dialog keeps waking up the NAS from its standby state (really irritating when I'm not wanting to view/use the NAS at that time and also bad for the hard drives to be stopped/started very frequently).
        Desktop PC: Intel Core-i5-4670 3.40Ghz, 16Gb Crucial ram, Asus H97-Plus MB, 128Gb Crucial SSD + 2Tb Seagate Barracuda 7200.14 HDD running Kubuntu 18.04 LTS and Kubuntu 14.04 LTS (on SSD).
        Laptop: HP EliteBook 8460p Core-i5-2540M, 4Gb ram, Transcend 120Gb SSD, currently running Deepin 15.8 and Manjaro KDE 18.

        Comment


          #5
          Thank you all. Rod J, here is the output of my mount command. The NAS is up and running, but the mount is ignored.

          Code:
          mark@AMD-64:~$ sudo mount -v -a
          [sudo] password for mark: 
          /                        : ignored
          /media/Data              : already mounted
          /media/NAS               : ignored
          And here is my fstab:
          Code:
          # <file system>                         <mount point>   <type>  <options>                    <dump>  <pass>
          # / was on /dev/sda1 during installation
          UUID=6bb8b708-55bf-4acd-bf77-b7f70d60d41b /               ext4    errors=remount-ro             0   1
          #
          # This is the data drive mounted to /media/Data
          UUID=9d3f1ff1-99b4-418c-8dca-84916431f9d5 /media/Data     ext4    auto,exec,rw,noatime          0   2
          #
          # This is the server mount of /nas
          192.168.1.105:/nas                        /media/NAS       nfs    rw,hard,noexec,noauto,user,retrans=1,retry=0          0   0
          Any ideas? BTW, I can ssh into the NAS without a problem. Oh, yeah. Here is my NAS share line in /etc/exports:
          Code:
          mark@nas64:~$ cat /etc/exports
          # /etc/exports: the access control list for filesystems which may be exported
          #               to NFS clients. See exports(5).
          #
          /nas 192.168.1.85/24(rw,sync)
          Now are there any ideas?
          "If you're in a room with another person who sees the world exactly as you do, one of you is redundant." Dr. Steven Covey, The 7-Habits of Highly Effective People

          Comment


            #6
            The command you issued will not mount your NAS by design. From "man mount" (emphasis added):
            Thefiles/etc/fstab,/etc/mtaband/proc/mounts
            The file /etc/fstab (see fstab(5)), may contain lines describing what devices are usually mounted where, using which options. The default location of the fstab(5) file can
            be overridden with the --fstabpath command-line option (see below for more details).

            The command

            mount-a [-ttype] [-Ooptlist]

            (usually given in a bootscript) causes all filesystems mentioned in fstab (of the proper type and/or having or not having the proper options) to be mounted as indicated,
            except for those whose line contains the noauto keyword. Adding the -F option will make mount fork, so that the filesystems are mounted simultaneously.
            "mount -a" means mount all those except those with "noauto" in their options. noauto means noauto. You have to specifically mount the NAS. Also, since you have "user" in there, you don't need sudo. Try

            mount /media/NAS

            Now, on to a more advanced approach. Assuming you want to mount the NAS automagically when you log in but only when it's on - and unmount it when you log off - you could use some scripts like this:

            Code:
            [FONT=monospace][COLOR=#000000]#!/bin/bash
            [/COLOR]# script to mount NAS if it's on
            if ping -c1 -w3 192.168.1.105 >/dev/null 2>&1
              then
                mount /media/NAS 
            fi
            [/FONT]
            Code:
            [FONT=monospace][COLOR=#000000]#!/bin/bash[/COLOR]
            # script to un-mount NAS if it's mounted 
            if [ $(mount | grep -c /media/NAS) = 1 ]
              then
                umount /media/NAS
            fi
            [/FONT]
            Create these scripts somewhere, make them executable, and add them to your log-on and log-off scripts in System Settings.

            Please Read Me

            Comment


              #7
              Thank you oshunluvr, the noauto option was the reason why sudo mount -a did not mount the NAS. The scripts work well, but where to put them so they work automagically? Of course, with those two scripts, wouldn't it be possible now to use systemd to mount the NAS conditionally? AKAIK, the mount script could just be added, and the umount script would have to be run AFTER reboot or shutdown command. What do you recommend?
              "If you're in a room with another person who sees the world exactly as you do, one of you is redundant." Dr. Steven Covey, The 7-Habits of Highly Effective People

              Comment


                #8
                Originally posted by mhumm2 View Post
                The scripts work well, but where to put them so they work automagically?
                As oshunluvr stated: "...add them to your log-on and log-off scripts in System Settings."
                Windows no longer obstructs my view.
                Using Kubuntu Linux since March 23, 2007.
                "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                Comment


                  #9
                  Click image for larger version

Name:	Screenshot_20181221_124034.jpg
Views:	1
Size:	49.2 KB
ID:	644075Screenie...
                  Last edited by oshunluvr; Dec 21, 2018, 11:47 AM.

                  Please Read Me

                  Comment


                    #10
                    It works well, thank you Snowhog. For my own edification, I'd like to better understand the scripts and relationship to the nfs line in my fstab. First of all, both scripts are still dependent on the nfs line in my fstab, correct? In other words, they won't work if I comment-out the nfs line. I read the ping help file and learned that -c is a count option, so -c1 outputs a single ping which is all that's necessary to determine if the server is up or down. -w is for deadline, but eliminating it from the ping command doesn't seem to make a difference nor does incrementing sequentially up to -w5. What is the purpose of the -w option then?

                    I also see from your screenshot, that you start Conky in the autostart section; nice. The last question I have, is what is the gui actually doing? Where in the OS is it actually running the symlinks it created, or what init or systemd file is it using to call those links? If I'm going to learn Kubunu, I need to know what's happening behind the scenes. Thanks again to all who replied.
                    "If you're in a room with another person who sees the world exactly as you do, one of you is redundant." Dr. Steven Covey, The 7-Habits of Highly Effective People

                    Comment


                      #11
                      If you remove the mount from fstab it won't mount. Without the mount in fstab giving you, the "user" permission to mount, the script would not be able to mount it because only root can do that unless you have "user" in the mount option if fstab.

                      The -w3 in the ping command allows it to fail (return an error) in three seconds if the NAS is not available. The point of the script was to mount the NAS if it was up when you logged in. If it's not on, how long would you want your login delayed waiting for it to come up? I picked 3 seconds because the is ample time for the ping to be returned but not so long as to be annoying. You can adjust it as you see fit. Likely 1 or 2 will work just as well, but I didn't know if you were on a wired or wireless connection.

                      Actually, I'm not sure if the script would even delay the log in or not. It might just be executed and then the login proceeds regardless of the script action.

                      As far as the GUI and the scripts, when you enter a script or program into the GUI, it copies the desktop file (for a program) into ~/.config/autostart and any scripts into ~/.config/autostart-scripts.
                      Last edited by oshunluvr; Dec 22, 2018, 02:28 PM.

                      Please Read Me

                      Comment


                        #12
                        The umount NAS script causes the client computer to hang and abort a shutdown when the server is turned off before the client computer. I removed the umount script from logoff and everything works fine. I don't think the nfs mount needs to be unmounted before the client computer shutsdown so it's all good. Thanks again to everyone who responded.
                        "If you're in a room with another person who sees the world exactly as you do, one of you is redundant." Dr. Steven Covey, The 7-Habits of Highly Effective People

                        Comment


                          #13
                          Yes, it would do that. You would need to unmount the server before turning it off regardless of how's it's mounted. Not doing so is the equivalent of unplugging a hard drive while using it. But I agree, there's is no real need to unmount it before shutting down a client. You would however want to unmount it before shutting it down.

                          Please Read Me

                          Comment

                          Working...
                          X