Mount Remote File System Using Fuse and sshfs

In one of the project we needed to store data in our data center i.e not place(store) it on cloud specifically. And this data needs to be available to multiple users/system. The operation on this data included creating/editing a file, copying a file from those stored data or copying to it.

After searching a few, we decided to use Fuse along with sshfs.

Fuse allows to use a  remote file as a local file and allows us to make changes to it that would reflect correctly on both the remote and local files.

Mounting a remote folder on ubuntu using Fuse(Filesystem in Userspace) and sshfs(Secure SHell FileSystem):

The stable release of fuse can be downloaed from : http://fuse.sourceforge.net/

Further installation can be done by :

./configure
make
sudo make install

Further installation of sshfs can be done by :

sudo apt-get install sshfs

Later we need to load the fuse using :

sudo modprobe fuse

Further the user needs to be assigned rights for performing action on fuse:

sudo adduser <username> fuse

The above command is used to add the user to the fuse module.

sudo chown root:fuse /dev/fuse
sudo chmod +x /dev/fusermount

While these command mentioned above are used to change the permission access of the file.

sudo chmod +x /dev/fusermount

might give an error namely directory not found.

In this case we can use the “whereis” command to locate usermount.

whereis fusermount

which would return a result something similar to
/usr/bin/fusermount

Using this location do :

sudo chmod +x /usr/bin/fusermount

After this do a logout and login back to the system.

Now make a directory named remoteserver to mount the remote folder.

mkdir ~/remoteserver

Now to mount the remotefolder on the remoteserver use :

sshfs <username>@<ipaddress>:/remotepath ~/remoteserver

Here the remotepath points to the remotefolder.

After this you will be prompted for the password.

Finally you will be able to use the remotefolder as if it was a part of the local system.
The remoteserver directory will contain all of the contents of the remotefolder.
Any changes made in the remoteserver will reflect in the remotefolder too.

For unmounting the remotefolder use :

fusermount -u ~/remoteserver

Using dd command to test

dd command is used to create a file :

dd if=/dev/zero of=output.dat  bs=10M  count=10240

Here the file named output.dat is created of size 100MB.

The bs option specifies the size of the file to be created.

To see the help of “dd”
Give a

dd --help

on the console.

Using dd command I created a file in the remotefolder by creating it in the remoteserver directory.
Also we tried copying the file along the network and compared the md5sum of the files to see if the files are correct.

md5sum filepath

In this case we can do it as,

md5sum output.dat

The transfer speed across the network came as 10 Mbps. This is dependent on the speed of the network.

Mounted filesystem can be used using the above explanation.

1 comments On Mount Remote File System Using Fuse and sshfs

  • I am trying to automate this process with sshpass but its not working. Here is the code:

    sshpass -p’password’ sshfs remoteserver@ipaddress:/remotefoler /localfolder

    When i do this it brings a pop up window asking for remote server’s password. I key in but it doesnt load remote folder’s contents.

    How can I use sshfs with sshpass?

Leave a reply:

Your email address will not be published.

Site Footer