How to Mount Raspberry Pi with SSHFS

How to Mount Raspberry Pi with SSHFS

Raspberry Pi is an amazing development device. I have two Pis constantly running on my home network performing different tasks. A few months ago my development stack became very diverse. Different versions of PHP, NodeJS, MariaDB, MongoDB, MySQL, Apache, Nginx and so on. Almost every project used different technologies and it`s a mess to install all the required software on my PC machine. To not pollute my home machine and not overhead RAM usage with virtual machines I decided to migrate backend related software to Pis. 

It turned out to work just fine. After the project is finished I can easily wipe out the SD card and reinstall raspbian for new projects. In some cases when I had to modify backend code easiest solution was to mount Pis directories directly to my Linux machine. In this blog post I will note full process, maybe someone will find it helpful as I did.

First of all, we need sshfs on our host computer:

sudo apt-get install sshfs

Then we can create a directory where we mount Pi:

mkdir pi

Then mount the Raspberry Pi`s filesystem to this location:

sshfs pi@ pi

Now enter this directory as if it is a regular folder; you should be able to see and access the contents of the Raspberry Pi:

cd pi && ls

You can also browse the Pi`s filesystem using your computer`s file manager (including drag-and-drop to copy files between devices), and use your computer`s applications (text editors, image processing tools, and so on) to edit files directly on the Pi.

Pi Folder Content

To safely unmount raspberry directory:

fusermount -u pi