Mount Remote Storage as Local Drives: A Guide to FUSE and SSHFS on Linux

Linux tutorial - IT technology blog
Linux tutorial - IT technology blog

Moving Beyond the SCP and SFTP Dance

Managing files across multiple servers usually involves a repetitive cycle of scp, rsync, or opening an SFTP client like FileZilla. While these tools work, they add friction to the development process. I used to spend 15 to 20 minutes just downloading log files to grep through them or uploading code patches one by one. Everything changed when I integrated FUSE (Filesystem in Userspace) and SSHFS into my daily routine.

FUSE is a kernel interface that lets non-privileged users create their own file systems without touching kernel code. This removes a major hurdle for DevOps engineers. You can mount a remote directory from a production server, an Amazon S3 bucket, or even a Google Drive account directly onto your local laptop. Once mounted, these remote files behave exactly like local data. You can use ls, cat, vim, or any GUI file manager as if the files were sitting on your NVMe drive.

On a production Ubuntu 22.04 server with 4GB of RAM, this approach significantly cut my data processing time. I once had to analyze 50GB of raw logs stored on a separate storage node. Instead of waiting 12 minutes for a network transfer, I mounted the node via SSHFS and ran my scripts immediately. The kernel handled the data streaming in the background, saving both disk space and my sanity.

Getting the Tools Ready

To start, you need to install the sshfs package. Most modern Linux distributions include this in their default repositories. Since SSHFS relies on FUSE, the installation typically pulls in all necessary dependencies automatically.

On Debian or Ubuntu-based systems, run:

sudo apt update
sudo apt install sshfs

For RHEL, CentOS, or AlmaLinux users:

sudo dnf install fuse-sshfs

After installation, check if your user needs to be part of the fuse group. On many modern distros like Ubuntu 22.04, this is handled automatically. If you encounter permission errors, try adding yourself manually:

sudo usermod -a -G fuse $(whoami)

Remember to log out and back in for this group change to take effect.

Mounting Remote Servers with SSHFS

SSHFS is remarkably simple. If you have SSH access to a server, you can mount its filesystem. You don’t need any special server-side configuration besides an active SSH daemon.

Basic Mount Command

Start by creating a local directory to act as the mount point. I usually keep mine in ~/mnt to stay organized.

mkdir -p ~/mnt/remote_server
sshfs user@remote-ip:/var/www/html ~/mnt/remote_server

Now, navigate to ~/mnt/remote_server. You will see the files from the remote /var/www/html directory. If you use SSH keys—which is highly recommended—the mount happens instantly without a password prompt.

The Non-Root Advantage

One standout feature of this setup is that you don’t need root access on your local machine to mount these drives. This is ideal for shared environments or restricted workstations. You can manage your own mounts without waiting for a sysadmin to approve a new data source connection.

Handling Cloud Storage (S3 and Rclone)

SSHFS is perfect for servers, but you might also need to touch Object Storage like AWS S3 or Backblaze B2. For this, I recommend rclone. It uses the same FUSE backend to mount cloud buckets.

# Example of mounting an S3 bucket after configuring rclone
rclone mount mys3bucket:bucket-name ~/mnt/s3_data --vfs-cache-mode writes

This treats a cloud bucket as a local folder. It is incredibly useful for backup scripts or applications that require a standard filesystem but need the infinite scaling of the cloud.

Optimization and Performance Tuning

Working over a network introduces latency. If you are on a connection with 100ms ping, a simple ls command might feel sluggish. A few specific flags can make the experience much smoother.

To speed up directory listings and file access, try these cache and compression settings:

sshfs user@remote-ip:/path ~/mnt/remote_server -C -o cache=yes -o kernel_cache -o compression=yes
  • -C: Enables compression, which is a lifesaver on slower links.
  • -o kernel_cache: Lets the kernel cache files to reduce redundant network requests.
  • -o auto_cache: Enables caching based on file modification times.

If your Wi-Fi blips or the server drops connections, add the reconnect option. This prevents the mount from hanging indefinitely:

sshfs user@remote-ip:/path ~/mnt/remote_server -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3

Verification and Monitoring

How do you verify the mount? The df -h command is the most reliable method. It lists the mounted filesystem and shows the remote server’s disk usage stats.

df -h | grep sshfs

When you are finished, do not use rmdir to remove the connection. Use the fusermount utility, which safely detaches FUSE filesystems:

fusermount -u ~/mnt/remote_server

Automating with fstab

You can add the mount to /etc/fstab to make it persist after a reboot. However, I advise against this for laptops. The boot process might hang if you aren’t on the right network. If you use it on a stable server, include the _netdev and allow_other options:

user@remote-ip:/path /home/localuser/mnt/remote_server fuse.sshfs _netdev,allow_other,IdentityFile=/home/localuser/.ssh/id_rsa 0 0

Troubleshooting Common Issues

Mounts sometimes become “stale” if a connection cuts out abruptly. You might see an error like “Transport endpoint is not connected.” In these cases, a standard umount usually fails. The fix is a forced, lazy unmount:

# Force unmount
fusermount -uz ~/mnt/remote_server

The -z flag cleans up the mount point as soon as the filesystem is no longer busy, resolving the hang immediately.

Using FUSE and SSHFS has fundamentally improved how I manage distributed infrastructure. It combines local convenience with remote power, letting me use my favorite editors and tools on data located anywhere. Give it a try the next time you find yourself trapped in a loop of scp commands.

Share: