0

I wish to set up a network drive for storing my personal photos. I already have a server and a 'pictures' user on the server. I planned to store the photos in the home directory of this user.

I already tried to set up an sshfs mount in fstab but that didn't quite work. I believe the reason was that my laptop is currently only on wifi and fstab would have required wired connection even when using _netdev option.

Then I saw this http://ubuntuforums.org/showthread.php?t=896474&p=5635104#post5635104 which adds mounting scripts to network if-up and if-down. But for some reason even that didn't work. When wifi connection was created the if-up script was not run.

Then I tried to use the "Connect to server" in Nautilus. This looked very promising and it sort of works. Only down side is that places connected with that option do not show up in browsers upload file dialog. And it would be one of the main use cases that I attach a picture to an email.

So my question is how could I mount a network drive so that: 1) the drive would be usable from applications like browser 2) it is automatically connected when network is available or when the bookmark or directory in Nautilus is clicked 3) Can be used by multiple users 4) easy to use even by nontechnical persons (setup can be more demanding)

Is there such a way?

Mika
  • 309
  • 1
  • 2
  • 16
  • What about Bit Torrent Sync like this: http://askubuntu.com/questions/284683/how-to-run-bittorrent-sync – jmunsch Jan 14 '14 at 22:06
  • Wouldn't Bit Torrent Sync actually download the content of the synced drive on your machine? My laptop has a smaller ssd drive so I can't store the pictures locally at all. – Mika Jan 15 '14 at 05:34

1 Answers1

1

Then I tried to use the "Connect to server" in Nautilus. This looked very promising and it sort of works. Only down side is that places connected with that option do not show up in browsers upload file dialog

Nautilus mounts those files under ~/.gvfs/share_name and they are available in the browsers upload file dialog from that directory too. Maybe the dialog hides that folder, because it is hidden, just press CTRL+H in the dialog to toggle showing hidden files/directories and browse to that folder.

To mount the same way as Nautilus mounts just use the command

gvfs-mount "ssh://user@host:port"

(Obviously filling out the parts correctly.) You can make a simple bash script with that command:

#!/bin/bash
sleep 20
gvfs-mount "ssh://user@host:port"

make it executable and make that script autostart with your login. (e.g. by typing "startup" in Dash and using the "startup applications" app to set it up.) This script will wait 20 seconds after startup to mount the share, if you need more or less time for the wifi to come up just change the number in the script to the seconds you want.

falconer
  • 15,026
  • 3
  • 48
  • 68
  • Well, yes in theory. I added a bookmark to that .gvfs/ directory into Nautilus, but when I clicked that bookmark in the upload file dialog it opened my servers root path and I needed to navigate to /home/pictures/ to find my pictures. I could do it but my wife shouldn't need to know the internal structure of my server. I forgot one requirement, 4) it should be usable by nontechnical persons. – Mika Jan 15 '14 at 05:27
  • @Mika The bookmark thing in Nautilus could be used to initiate the connection and make the mount, but it will mount the whole share. To access the files easily just make a symlink to the remote directory you want, e.g. with ln -s ~/.gvfs/share_name/home/pictures name_for_the_link and use this symlink to access that particular folder. You can make that symlink in any directory you want. Of course the link will be broken when the server is not connected, but then you just click that bookmark in Nautilus and everything is in order. – falconer Jan 15 '14 at 07:01
  • This sounds good. But could that connecting part be automated in anyway? Would be awesome if Nautilus could run a script when it is started. I found some story about Nautilus scripts http://g-scripts.sourceforge.net/, but saw nothing about running them when Nautilus starts. If it could run a script when it start, then I think it could also run a simple sshfs command to mount the drive. – Mika Jan 15 '14 at 11:45
  • @Mika Of course it can be. But seeing your luck with the automounting I didn't propose it. :) If you autostart it only with your login it should be fine. – falconer Jan 15 '14 at 12:14
  • Thanks, I'll try that out when I get to home. Though I think the script needs some modification to work on wifi. I believe the startup applications are run before the wifi connection is established. – Mika Jan 15 '14 at 13:07
  • @Mika You can put in some sleep of course, but I think Ubuntu starts setting up the wifi connection before you login. At least I already have wifi connection at the login screen with lubuntu 13.10. So I think that this is only a problem if you have slow wifi handshake or you use autologin. – falconer Jan 15 '14 at 13:14
  • My 12.04 doesn't start the wifi so early, but I (and my wife) can click that bookmark to mount the drive. Thank you for your help! – Mika Jan 24 '14 at 22:47
  • @Mika Did you try then putting in some sleep? I updated my answer like how I meant to do it. The script will just sleep that many seconds and then try the mount. – falconer Jan 25 '14 at 20:38
  • Putting some sleep before command works well. Now it mounts automatically. Thanks :) – Mika Jan 26 '14 at 19:33
  • Btw, I opened another question http://askubuntu.com/questions/410696/image-preview-from-remote-drive about the preview images. If you have some advice on that. – Mika Jan 26 '14 at 19:34