Announcement

Collapse
No announcement yet.

Autofs configuration with NFSv4 - use systemd instead

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

    Autofs configuration with NFSv4 - use systemd instead

    I'm trying to switch my NFS mounts to autofs because no matter what I set in fstab, the server being unavailable renders my desktop unusable.

    I have configured /etc/auto.master as:
    Code:
    [FONT=monospace][COLOR=#000000]#[/COLOR]
    # Sample auto.master file
    # This is a 'master' automounter map and it has the following format:
    # mount-point [map-type[,format]:]map [options]
    # For details of the format look at auto.master(5).
    #
    #/misc  /etc/auto.misc
    /shared /etc/auto.nfs
    #
    # NOTE: mounts done from a hosts map will be mounted with the
    #       "nosuid" and "nodev" options unless the "suid" and "dev"
    #       options are explicitly given.
    #
    #/net   -hosts
    #
    # Include /etc/auto.master.d/*.autofs
    # The included files must conform to the format of this file.
    #
    +dir:/etc/auto.master.d
    #
    # Include central master map if it can be found using
    # nsswitch sources.
    #
    # Note that if there are entries for /net or /misc (as
    # above) in the included master map any keys that are the
    # same will not be seen as the first read key seen takes
    # precedence.
    #
    +auto.master
    [/FONT]
    and the above referenced /etc/auto.nfs as:
    Code:
    [FONT=monospace][COLOR=#000000]-fstype=nfs4,bg,hard,timeo=50,retrans=5,actimeo=10,retry=5,intr,users,rsize=131072,wsize=131072,noatime,nodiratime server:/[/COLOR]
    [/FONT]
    which is the fstab entry with the -fstype=nfs4 option added as directed by various internet searches and I've mad no changes to /etc/autofs.conf. CHecking the status of autofs results in :
    Code:
    [FONT=monospace][COLOR=#54FF54][B]stuart@office[/B][/COLOR][COLOR=#000000]:[/COLOR][COLOR=#5454FF][B]~[/B][/COLOR][COLOR=#000000]$ sudo service autofs status      [/COLOR]
    [COLOR=#54FF54][B]●[/B][/COLOR][COLOR=#000000] autofs.service - LSB: Automounts filesystems on demand[/COLOR]
       Loaded: loaded (/etc/init.d/autofs; bad; vendor preset: enabled)
       Active: [COLOR=#54FF54][B]active (running)[/B][/COLOR][COLOR=#000000] since Sun 2018-05-20 12:55:30 EDT; 7h ago[/COLOR]
         Docs: man:systemd-sysv-generator(8)
      Process: 8650 ExecStop=/etc/init.d/autofs stop (code=exited, status=0/SUCCESS)
      Process: 8661 ExecStart=/etc/init.d/autofs start (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/autofs.service
               └─8673 /usr/sbin/automount --pid-file /var/run/autofs.pid
    
    May 20 12:55:30 office systemd[1]: Starting LSB: Automounts filesystems on demand...
    May 20 12:55:30 office autofs[8661]:  * Starting automount...
    May 20 12:55:30 office autofs[8661]:    ...done.
    May 20 12:55:30 office systemd[1]: Started LSB: Automounts filesystems on demand.[/FONT]
    which looks OK, but the nfs export does not mount. It mounts fine using fstab and via a manual mount.

    Ideas?

    Please Read Me

    #2
    I do see this in "mount' but no files are listed :

    /etc/auto.nfs on /shared type autofs (rw,relatime,fd=6,pgrp=9905,timeout=300,minproto=5 ,maxproto=5,indirect,pipe_ino=393668)


    Please Read Me

    Comment


      #3
      Time to use systemd?
      https://cloudnull.io/2017/05/nfs-mount-via-systemd/

      http://man7.org/linux/man-pages/man7/nfs.systemd.7.html

      Catch you in the morning....zzzzzz
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Your auto.nfs needs a little help. I don't see any directories listed there - so autofs doesn't know what directories to create. Here's mine - I use the same file for server and laptop and just comment out the lines I don't need -
        Code:
        #laptop-home		-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.101:/home/wizard
        #laptop-etc		-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.101:/etc
        #laptop-internal		-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.101:/mnt/internal
        #laptop-external		-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.101:/mnt/external
        server-home		-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.102:/home/wizard
        server-etc		-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.102:/etc
        server-external	-fstype=nfs,rw,nosuid,soft,rsize=16384,wsize=16384,intr,noatime	192.168.1.102:/mnt/external
        we see things not as they are, but as we are.
        -- anais nin

        Comment


          #5
          Correct me if I'm wrong, but according to the remarks in auto.master, that is where you list the mount points like I have here:
          /shared /etc/auto.nfs
          and in this part of the your server-external line above:
          192.168.1.102:/mnt/external
          The IP is the server IP and /mnt/external refers to the name of the exported folder from the nfs server, not the mount location. NFSv3 exports the individual folders like you have. However, I am using NFSv4 which does not export in that way. My export line looks like:
          /exports 192.168.1.0/24(rw,fsid=0,crossmnt,no_subtree_check,async,secur e,nohide,all_squash,anonuid=65534,anongid=560)
          and all the subfolders mounted below /exports are shown when you mount the server. The mount line from fstab looks like:
          server:/ /shared nfs noauto,bg,soft,timeo=50,retrans=5,actimeo=10,retry =5,intr,users,rsize=131072,wsize=131072,noatime,no diratime,x-systemd.automount 0 0
          Note the lack of explicit directories in the fstab mount.

          So you're saying even though the NFSv4 mount doesn't require a directory name, autofs does? I'll try that and report.

          Please Read Me

          Comment


            #6
            So now my auto.nfs looks like this:
            server -fstype=nfs4,rsize=131072,wsize=131072,noatime,nodi ratime server:/exports
            and a check of the status of autofs reveals a clue:
            Code:
            [FONT=monospace][COLOR=#54FF54][B]●[/B][/COLOR][COLOR=#000000] autofs.service - LSB: Automounts filesystems on demand[/COLOR]
               Loaded: loaded (/etc/init.d/autofs; bad; vendor preset: enabled)
               Active: [COLOR=#54FF54][B]active (running)[/B][/COLOR][COLOR=#000000] since Mon 2018-05-21 09:04:18 EDT; 5min ago[/COLOR]
                 Docs: man:systemd-sysv-generator(8)
              Process: 1250 ExecStart=/etc/init.d/autofs start (code=exited, status=0/SUCCESS)
               CGroup: /system.slice/autofs.service
                       └─1600 /usr/sbin/automount --pid-file /var/run/autofs.pid
            
            May 21 09:04:15 office systemd[1]: Starting LSB: Automounts filesystems on demand...
            May 21 09:04:18 office autofs[1250]:  * Starting automount...
            May 21 09:04:18 office autofs[1250]:    ...done.
            May 21 09:04:18 office systemd[1]: Started LSB: Automounts filesystems on demand.
            May 21 09:04:29 office automount[1600]: [COLOR=#FF5454][B]key "Incoming" not found in map source(s).[/B][/COLOR][COLOR=#000000][/COLOR]
            May 21 09:04:29 office automount[1600]: [COLOR=#FF5454][B]key "Downloads" not found in map source(s).[/B][/COLOR][COLOR=#000000][/COLOR]
            May 21 09:04:29 office automount[1600]: [COLOR=#FF5454][B]key "Documents" not found in map source(s).[/B][/COLOR][COLOR=#000000][/COLOR]
            May 21 09:04:31 office automount[1600]: [COLOR=#FF5454][B]key "Pictures" not found in map source(s).[/B][/COLOR][COLOR=#000000][/COLOR]
            May 21 09:04:31 office automount[1600]: [COLOR=#FF5454][B]key "Projects" not found in map source(s).[/B][/COLOR][/FONT]
            I don't know why it only lists five subfolders as there are 14 in the /exports folder on my server, but I'm getting closer.

            Please Read Me

            Comment


              #7
              Originally posted by oshunluvr View Post
              May 21 09:04:15 office systemd[1]: Starting LSB: Automounts filesystems on demand...
              May 21 09:04:18 office autofs[1250]: * Starting automount...
              May 21 09:04:18 office autofs[1250]: ...done.
              May 21 09:04:18 office systemd[1]: Started LSB: Automounts filesystems on demand.
              May 21 09:04:29 office automount[1600]: key "Incoming" not found in map source(s).
              May 21 09:04:29 office automount[1600]: key "Downloads" not found in map source(s).
              May 21 09:04:29 office automount[1600]: key "Documents" not found in map source(s).
              May 21 09:04:31 office automount[1600]: key "Pictures" not found in map source(s).
              May 21 09:04:31 office automount[1600]: key "Projects" not found in map source(s).
              [/CODE]I don't know why it only lists five subfolders as there are 14 in the /exports folder on my server, but I'm getting closer.
              What is different about the other 9 folders (their naming), if anything, from the 5 above that aren't found?
              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


                #8
                None.
                ls /exports
                Alt_Movies Audio Backups Documents Downloads Home_Movies Incoming Movies Music Music_Videos Pictures Projects TV_Shows Videos
                This time, after a reboot, it only lists four folder (the previous ones minus "Incoming").

                I tried killing autofs and making the folder for Incoming, but it just hides it when restarted. If I have to "map" every folder to use autofs, it totally defeats the purpose of using NFSv4. With v4 you don't have to export or mount every folder, just one - the "host" folder.

                Looking into systemd.automount now...

                Please Read Me

                Comment


                  #9
                  So with systemd, you don't need autofs at all. I rearranged and added to my nfs line in fstab so now it looks like:
                  server:/ /shared nfs noauto,x-systemd.automount,x-systemd.device-timeout=10,bg,hard,intr,rsize=131072,wsize=131072, noatime,nodiratime 0 0
                  After reboot, the "noauto" prevents a slow or stopped boot up if the server is off-line, but as soon as I access the mount point /shared, systemd attempts to mount the nfs share and does if it's available. I added the timeout option so systemd will give up after 10 tries, but reportedly it doesn't bog your system down like a failed nfs mount will.

                  Thanks to you all for your help, and a special thanks to GG for the hint.

                  I had seen this in action already sort-of because I could not unmount the nfs share while playing with this unless I took the fstab line out. Prior to the above, I had "auto" but had also added the "systemd-automount" at the end of the line. "auto" caused a system hang and systemd-automount prevented it from unmounting. I recall I had added that last bit some time ago when playing with systemd features but had basically forgotten it until now.
                  Last edited by oshunluvr; May 21, 2018, 07:47 AM.

                  Please Read Me

                  Comment

                  Working...
                  X