Announcement

Collapse
No announcement yet.

Automatically mount network drive

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

    Automatically mount network drive

    I have network drive. I put it into "Places" in Ubuntu and similarly can access it from Kubuntu.
    It suits me almost all right. When I need it, I go to "Places" and click folder name there. Drive is mounted at this point of time and can be used.
    But sometimes I forget to mount it. And also "places" is not the easiest place to access the files via pop-up windows within the programs.
    Is it possible to mount drive automatically somehow?
    What I have tried so far:
    1) Create a script in Autostart folder
    2) Configure fstab.
    Both do not help. Most likely because network is down when fstab or Autostart is executed. Since network is down, OS cannot access network drive and cannot mount it.

    Are there any other options?
    Thanks!
    http://linuxblog.darkduck.com

    #2
    Re: Automatically mount network drive

    What type of network drive are you trying to mount? You can set an smb network drive to automount in Dolphin.
    Registered Linux user #346571

    Comment


      #3
      Re: Automatically mount network drive

      This is FND (Freecom Network Drive). 1Tb.
      What do you mean by "automount"?
      http://linuxblog.darkduck.com

      Comment


        #4
        Re: Automatically mount network drive

        re fstab: By the network being down, do you mean your computer because it was off or do you mean your router or the computer connected to your networked drive is off? The statement that fstab can't work in these scenario is simply untrue. It may not work the way you think it should or the correct options haven't been used but it certainly works for others - me included.

        Start by detailing how your network drive is connected and how you're accessing it, what you've tried so far and your results, and then detail exactly how you would like it to work.

        Then we can come up with the best way to fix this for you.

        Please Read Me

        Comment


          #5
          Re: Automatically mount network drive

          I use WiFi network to connect laptop to the Internet.
          FND is connected via usual cable directly to WiFi router.
          FND and router are always on.
          When I turn on my laptop and load (K)Ubuntu, there is no network for few seconds after boot. Pop-up splash screen comes few seconds after telling me that network is connected. That's why I was thinking about fstab not able to connect.
          I tried fstab with same parameters as I use for "mount -t cifs..." command in terminal. No results, obviously.

          Now I use Places and can access network drive via .gvfs, which is not the shortest and easiest way in "Open file" interface.
          I want network drive to be mounted something like /fnd and available when I need it. I understand that it won't be there until network is up and running. But as soon as network is there, I'd like it to be available. Just like in Windows Explorer (sorry for rude words in this forum).
          http://linuxblog.darkduck.com

          Comment


            #6
            Re: Automatically mount network drive

            mounting via fstab would be the correct way to do this.
            althought if possible you should use nfs as it if faster then smb (if the box supports it)

            the problem is that using Network Manager to handle the wifi is going to wait untill you log in to connect.(way after fstab is checked) you can fix this a few ways, you can write a mount script containg the mount command used to mount the disk. you can try to use another network manager like wicd to see if it starts the wifi eariler.i would take the first path and write a simple mount script something like

            [code=mount.sh]
            mount <path to share> <mount point>
            [/code]
            then put it in ~/.kde/Autostart and change is owner to root. so you can mount w/o dialog on login.
            Mark Your Solved Issues [SOLVED]
            (top of thread: thread tools)

            Comment


              #7
              Re: Automatically mount network drive

              It's definitely a bit tougher using wireless.

              Another solution is to put the mount command in your fstab with the options "noauto,users".

              This will not mount the drive at boot, but will mount it when you try to access it - assuming the network is up. The advantage of this method is a slightly faster boot. The dis-advantage is any files wouldn't be available to you until you mount it.

              This works great if you're using the drive for file storage and backups - stuff like that. If you have files or media stored on it that you want to access directly (not via dolphin) you'd want the automount script like sithlord suggests.

              Please Read Me

              Comment


                #8
                Re: Automatically mount network drive

                Originally posted by sithlord48
                mounting via fstab would be the correct way to do this.
                althought if possible you should use nfs as it if faster then smb (if the box supports it)

                the problem is that using Network Manager to handle the wifi is going to wait untill you log in to connect.(way after fstab is checked) you can fix this a few ways, you can write a mount script containg the mount command used to mount the disk. you can try to use another network manager like wicd to see if it starts the wifi eariler.i would take the first path and write a simple mount script something like

                [code=mount.sh]
                mount <path to share> <mount point>
                [/code]
                then put it in ~/.kde/Autostart and change is owner to root. so you can mount w/o dialog on login.
                I used the script option, but it did not work. Probably because owner was not root. I'll give it another go.
                http://linuxblog.darkduck.com

                Comment


                  #9
                  Re: Automatically mount network drive

                  Originally posted by sithlord48
                  ...you can write a mount script containg the mount command used to mount the disk. you can try to use another network manager like wicd to see if it starts the wifi eariler.i would take the first path and write a simple mount script something like

                  [code=mount.sh]
                  mount <path to share> <mount point>
                  [/code]
                  then put it in ~/.kde/Autostart and change is owner to root. so you can mount w/o dialog on login.
                  Or you could both start the wireless connection and mount the drive in /etc/rc.local
                  we see things not as they are, but as we are.
                  -- anais nin

                  Comment


                    #10
                    Re: Automatically mount network drive

                    Originally posted by wizard10000
                    Or you could both start the wireless connection and mount the drive in /etc/rc.local
                    I am afraid that is not an option. Wireless takes some [significant] time to fire up. If I just add 2 lines into rc.local, this won't help.
                    I have a script in Puppy which checks wireless presence before mounting the drive. I'll write similar in Kubuntu.
                    Code:
                    #! /bin/sh 
                    #reset counter and file
                    counter=0
                    file="/tmp/file.txt"
                    echo $counter > $file
                    
                    until ping -w 1 fnd | grep 'seq'
                    do
                     sleep 1
                     let "counter += 1"  #или counter=`expr $counter + 1`
                    #get ipconfig replies and counter into file
                     ping -w 1 fnd | grep 'seq' >> $file
                     echo "$counter" >> $file
                    done
                    
                    #main part
                    mkdir -p /mnt/fnd >> $file
                    mount -t cifs //fnd/public /mnt/fnd -o guest,nolinux,iocharset=utf8 >> $file
                    #check script has worked
                    chrome
                    http://linuxblog.darkduck.com

                    Comment


                      #11
                      Re: Automatically mount network drive

                      Originally posted by darkduck
                      ...If I just add 2 lines into rc.local, this won't help.
                      Nobody said anything about adding just two lines

                      Your script looks good. I've got a wireless connection at work that has to be scripted and the last line in the script calls dhclient. When dhclient gets an IP address you can mount the drive.

                      There's more than one way to skin a cat. You method loops until you have an IP address and mine waits until you have one. One of the really cool things about this geek stuff is having choices
                      we see things not as they are, but as we are.
                      -- anais nin

                      Comment


                        #12
                        Re: Automatically mount network drive

                        Tested the script. Works OK. Only had to replace seq with icmp, because seq substring did not appear in my ping command.
                        Now I am OK in Kubuntu. Need to do the same in Ubuntu. What is the place there similar to ~/.kde/Autostart?
                        http://linuxblog.darkduck.com

                        Comment


                          #13
                          Re: Automatically mount network drive

                          Originally posted by darkduck
                          Now I am OK in Kubuntu. Need to do the same in Ubuntu. What is the place there similar to ~/.kde/Autostart?
                          Seems like I found an answer myself
                          http://ubuntuforums.org/showthread.php?t=1625794
                          will try later.
                          http://linuxblog.darkduck.com

                          Comment


                            #14
                            Re: Automatically mount network drive

                            Unfortunately, this method did not work. Don't know why...
                            Any suggestions?
                            http://linuxblog.darkduck.com

                            Comment

                            Working...
                            X