Announcement

Collapse
No announcement yet.

Automount network drives using NFS

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

    Automount network drives using NFS

    Hi,
    I have 2 computers, a desktop and a laptop, both running Kubuntu 11.10. What I am looking for is a really detailed setup for a network connection between those 2 computers using automount and NFS.
    I have done it before using just NFS and as soon as one of the computers shuts down, the other one hangs because the network connection is still open. This happens btw both in samba and NFS, but only in the KDE version. With Gnome I never saw this.
    Please somebody, explain to me in detail (and I really mean detail) how I can setup this connection so I won't have a hanging computer again.

    Some details which you might use when writing the explanation:

    shared drives on both computers: /home/DeMus
    mount point on both computers: /home/DeMus/shares/ext-homedrive
    external drives should be read-write accessible without passwords, guest access is fine with me

    Please explain which packages I have to install on a clean Kubuntu setup, which files I have to add/change, etc, etc.

    I know I ask much but I am so fed up with the issue I have. I love KDE, I really do, but I can't get these connections the way I want them. I have found several how to's on the net but somehow these don't work for me.
    I will be forever in your debt when you can help me to fix this problem.
    Thank you so much.

    DeMus

    #2
    By "Automount" what exactly do you mean?

    NFS drives can by mounted "on-the-fly" or soft-mounted but that can be problematic. Preferred is to "hard" mount them and use the intr option which allows interrupts.

    NFS is rather easy to set up. Use properly defined host names and mount via fstab. You can opt for "noauto" and "users" options which allow the boot process to proceed without hanging and the NFS share can be mounted with a click within dolphin.

    Install nfs-common and nfs-kernel-server on both computers, export the shared folders on both computers, mount with the proper options. I use NFS with my server and desktop and several laptops. In my case the desktop mounts the server exports at boot but the laptops don't.

    Read/write access is best handled by owner/group permissions. How to do that depends on your desires - solo user or multiuser and so on. Gice a more detailed description of what you've tried and how it failed along with what you want.

    I presume with a laptop/desktop set up you would have the desktop mount the NFS share at boot time (with intr) and the laptop not mount at boot time but have the share available to mount on demand.

    Please Read Me

    Comment


      #3
      Thank you for your reply. I know how to setup NFS, well anyway using fstab but that's just it: I would rather not use fstab since I get problems when doing so.
      When I used NFS I export directories using exports and I mounted them using fstab. When the computer was on this would work great but as soon as I would switch that one off, this one would hang. Dolphin doesn't do anything anymore, the kickoff menu would freeze, I just had to switch off the computer using the power button.
      Now I have heard about automount or autofs which would only mount a share when it is needed and after a time-out (programmable length of time) it would unmount again. That way the connection to the other computer is closed and it is OK to switch it off.
      I have tried using it, read some how to's on the internet but somehow I can't get it right. How does it work and please talk me through the setup in detail cause otherwise I think I will never get it to work.

      Thank you so much.

      Comment


        #4
        I don't use autofs and never needed it. I suspect your fstab mounting line needs improvement.

        Please Read Me

        Comment


          #5
          Sorry it's not super detailed and its for smb not nfs.
          I did this twice tonight neither machine was clean install.
          One was with sshfs with preshared keys and what you see here smb.
          I made two mistakes one on each install. Both mistakes were typos I caught on re-reading .
          I had fstab issues on resume for a htpc so thought id try this.


          The "smbfs" package provides the tools needed to mount "smbfs" and "cifs" filesytems. You may have smbfs installed on your machine. If not, run
          Code:
          sudo apt-get install smbfs
          I didnt do this and so far no shutdown issues
          Update the unmount order to prevent CIFS from hanging during shutdown.
          sudo update-rc.d -f umountnfs.sh remove
          sudo update-rc.d umountnfs.sh stop 15 0 6 .
          install autofs
          sudo apt-get install autofs

          create a mount point mine is /home/sluckxz/mount


          edit /etc/auto.master
          /home/sluckxz/mount /etc/auto.cifs --timeout=600 --ghost
          create file /etc/auto.cifs
          add
          folder4t -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.0.12/t
          create /etc/credentials.txt
          add
          user=username
          password=password

          everytime you change anything restart autofs
          sudo restart autofs

          Comment


            #6
            @Sluckxz
            Thanks so much, will try it out this evening

            Sorry, it will take a bit longer. Probably in the weekend when I have time to do this. Will report back though.
            Last edited by DeMus; Mar 14, 2012, 10:56 PM.

            Comment


              #7
              I did try and it doesn't work. I have several questions:
              you write:
              folder4t -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.0.12/t
              What is 4t (at the beginning) and what is /t (at the end)
              Do I really need to write the whole paths in auto.master and in auto.cifs? Isn't that double?
              How do I tell the computers to use nfs instead of cifs? Do I also have to use all the text files normally used for nfs?
              Please somebody help me do this. It is driving me crazy. I have a wonderful setup with my 2 KDE machines but I want to have a working network as well. Don't make me go back to the horrible Gnome with their version 3.
              Thank you

              Comment


                #8
                One more time: Can somebody please write an extensive how-to about the combination of autofs and nfs on Kubuntu 11.10? And I really mean a detailed explanation inwhich every step is described, every install, every text file which needs to be changed, everything. Please. Please help me. This is driving me crazy.

                Comment


                  #9
                  Originally posted by DeMus View Post
                  I did try and it doesn't work. I have several questions:
                  you write:
                  folder4t -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.0.12/t
                  What is 4t (at the beginning) and what is /t (at the end)
                  Do I really need to write the whole paths in auto.master and in auto.cifs? Isn't that double?
                  How do I tell the computers to use nfs instead of cifs? Do I also have to use all the text files normally used for nfs?
                  Please somebody help me do this. It is driving me crazy. I have a wonderful setup with my 2 KDE machines but I want to have a working network as well. Don't make me go back to the horrible Gnome with their version 3.
                  Thank you
                  folder4t at the beginning is the folder autofs will automagically create and mount the folder smb:/192.168.0.12/t.
                  192.168.0.12/t is the smb shared folder on the remote machine.
                  auto.master is the local machine path for folder4t /home/sluckxz/mount /etc/auto.cifs --timeout=600 --ghost
                  when it works /home/sluckxz/mount/folder4t is where the remote files will be

                  auto.cifs
                  folder4t -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.0.12/t
                  they are different.
                  credentials.txt is not needed if you dont need credentials to logon to the smb share.

                  Comment


                    #10
                    Thank you again Sluckxz. The folder names you use are these the real names I have to use or do I use my own folder instead? What I mean is, is folder4t the actual name autofs creates?

                    Comment


                      #11
                      And there was light.
                      Finally I have things working. This is how I did it:
                      On the website NFS HOW TO I got all the info I need to setup an NFS connection between my 2 computers.
                      Then I wanted the autofs to kick in.

                      Install the autofs package, which is in the standard repositories of (K)ubuntu and LinuxMint.
                      Then edit the file: /etc/auto.master
                      Here you can setup the base mount point, write down the file name of the file where the details about the mount are placed and I used the time-out function. Auto.master for me looks like this:
                      Code:
                      /-  /etc/auto.home --timeout=5
                      /-  /etc/auto.video --timeout=5
                      This means:
                      /- tells that the basepoint for the shares is the root directory
                      Further details about a share can be found in the files mentioned and both shares use a timeout of 5 sec. This means after 5 sec of in-activity the connections is automatically unmounted. Yeah!

                      /etc/home looks like this:
                      Code:
                      /mnt/LinuxDesktopHome -rw,soft,intr 192.168.1.21:/home/<username>
                      /mnt/LinuxDesktopHome = the mount point I chose
                      -rw,soft,intr are the options I use
                      <ip-address>:/home/<username> is the shared home directory on the computer with the mentioned ip-address.

                      The file /etc/auto.video looks almost the same only the mount point and the shared folder name are different.
                      Use filenames like auto.xxxx for the maps files.

                      When the files have been created it is just the matter of reloading the new data in the autofs service:
                      Code:
                      sudo service autofs reload
                      and restart the service
                      Code:
                      sudo service autofs restart
                      Now I can just switch off one computer and continue to work on the other without having to reboot it first.

                      Thanks for all who contributed in this thread.
                      Last edited by Snowhog; Mar 28, 2012, 11:09 PM.

                      Comment


                        #12
                        Bought a laptop and wanted to backup the laptop to the storage drives on my desktop - I have 3 drives there, 2 for independent backup. So followed the steps in the HowTo mentioned.

                        3 things:
                        1. portmap has been replaced by rpcbind - no configuration file to modify. Also a different entry in /etc/hosts.allow. Replaced 'portmapd' line with 'rpcbindd' line.
                        2. as soon as I saved the modified '/etc/fstab' file, the two computers were connected and the drives mounted. one partition on the desktop presented a few problems, but only because I had the mountpoints incorrect. corrected and it was mounted automatically.
                        3. For my use 'autofs' doesn't seem to be necessary. Either computer can be off or disconnected from the network and the other computer works just fine.

                        Question: in replacing portmap, I used 'rpcbindd' in the 'hosts.allow' file. I assumed that the rpcbind daemon would follow the usual naming convention of just adding a 'd' to the end of the name. Is there another name for the rpcbind daemon that should be used?? I haven't seen any error messages so am not too sure.

                        Have written the scripts to do the backup of the laptop to the desktop storage drives already. The whole process took less time than finding and just reading the necessary documentation. Now I no longer worry about losing the drive on the laptop.

                        Thanks to those who pointed to the needed documentation.

                        Comment


                          #13
                          Update on my network connection between my desktop and laptop over my in-house LAN.

                          Both are connected through a router/DSL modem using Ethernet (not too sure I trust wireless yet - it is easier to use, but). Anyway, I was wrong in my previous post about the computers not hanging when one is disconnected or shutdown. The other computer does hang until the disconnected/shutdown computer is brought back online.

                          I have resolved this problem and the solution is fairly easy via the 'fstab' entry.

                          I modified the fsatb entry thus:

                          # NFS files on Laptop
                          192.168.0.300:/home/my-user-name /home/laptop/my-user-name nfs rw,hard,intr,noexec,users,_netdev 0 0

                          The difference is the addition of "users,_netdev". "users" allows any user to unmount from the mount point. Strictly speaking this is not necessary since it is possible to write a script unmounting the files and execute the script with 'sudo' or 'kdesudo'. It is just easier for me this way since I can click on the "USB" icon in the panel and unmount as needed.

                          The "_netdev" addition instructs that the files are not mounted unless the network is connected.

                          To turn off or disconnect one computer without hanging the other computer, I simply unmount the network mounts on both computers. I can then disconnect or shutdown either computer without hanging the other.

                          It would be nice to have the unmounts done automatically when the network connection is broken, but until then this works and is simple, quick and easy to do.

                          Comment

                          Working...
                          X