Question

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.

Was it helpful?

Solution

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top