2

I want to use sshfs to mount folders from my server to my laptop.

Ive been doing this my making a directory, for example making the dir mount under my desktop

mkdir ~/Desktop/mount

and then I would use sshfs to mount to that

sshfs user@ipaddress:path/to/file ~/Desktop/mount -o volname=Something

This works just fine. Except that I have to make that directory first. I wrote a script to make the dir for me and mount it

umount ~/Desktop/mount
rm -rf ~/Desktop/mount
mkdir ~/Desktop/mount
sshfs ichill@192.168.1.142:$1 ~/Desktop/mount -o volname=$1

The problem then is trying to make multiple mounts. So, I revised the above code to make multiple mounts

umount ~/Desktop/$1
rm -rf ~/Desktop/$1
mkdir ~/Desktop/$1
sshfs ichill@192.168.1.142:$1 ~/Desktop/$1 -o volname=$1

No the problem is, I get left with sometimes 4 to 5 empty folders.

Is there a way to make this mount without having to make folder each time.

EDIT: I also dont want to make a script to unmount it. I would like to use the system eject calls.

Cripto
  • 3,581
  • 7
  • 41
  • 65

1 Answers1

3

No, it is required to have a containing folder to make a successful mount

Seeing as youre aiming your desktop folder - i assume you are looking for the similar behavior of the desktop-system (e.g. gnome) when using 'mount server' facilities.

To achieve this with gnome-virtual-filesysem (GVFS) you could issue this command instead.

gvfs-mount sftp://user@host:port 

It will create a folder under .gvfs called 'sftp for user on host' where user and host are set by you. Also, it should present itself under your Nautilus explorer windows.

The gvfs-mount uses GIO from Glib which is a Gnome speciality. In this library it can monitor the mount folder and thus deletes it once unmounted.

To unmount a gvfs connection, usage is a bit different then regular mount as it uses the gvfs-mount binary to do so.

ls ~/.gvfs
>> outputs
/home/user/.gvfs/sftp for user on host
# to umount: (-u in short)
gvfs-mount --unmount "/home/user/.gvfs/sftp for user on host"
mschr
  • 8,531
  • 3
  • 21
  • 35
  • 1
    Ah. Thanks for the input, but the laptop im using is a mac. I dont have gvfs. No can I get it (easily). – Cripto Aug 10 '12 at 07:49
  • im afraid you cant Glib is quite extensive. Im not sure though but i guess it would be possible to compile your own version - but your mac would have to be setup with stuff like automake, m4, gcc etc. Look in this google search http://alturl.com/57unn for gnome.org stuff or in the macports.org here http://alturl.com/pbggd – mschr Aug 10 '12 at 08:03