Walker News

Map Linux Network Drive With SHFS Module

When the Linux servers are running low of disk space, you may want to add additional hard disks. But, the limited SCSI or SATA hard disk I/O connectors are all fully used up.

For non-critical application or quick solution, it’s possible to temporarily increase Linux free disk space with an USB to SATA converter, external SATA connector, or mount a remote Linux file system as network drive!

Though there are many ways create a Linux network drive, I would like to document the Secure Shell FileSystem (shfs) approach.

As suggest by SHFS tagline “Mount ANY dir from ANY host in a SECURE way”, you don’t have to setup a Samba server and explicitly create shared resources, only a workable SSH server will do the job!

SHFS is a lightweight Linux kernel module (similar to smbfs, ftpfs or ncpfs) used to securely mount remote folders or filesystems as Linux network drive via SSH protocol! Other than providing SSH security feature, shfs also supports persistent connection and file cache data structure to speed up I/O performance.

How to compile and setup SHFS or Secure Shell FileSystem?

This guide is tested on Red Hat Linux 9
  1. Download SHFS v0.35 source code (latest version at official site),
  2. Execute tar -zxvf shfs-0.35.tar.gz to uncompress (untar) the gzipped tarball,
  3. Execute cd shfs-0.35 to change directory to the untar folder,
  4. Execute make to compile the SHFS source code with GCC compiler (the same GCC compiler that compile the host kernel),
  5. Execute cd shfs/Linux-2.x to change directory to shfs sub-folder, where the Linux-2.x is the host kernel version (i.e. uname -r),
  6. Execute insmod shfs.o to install the SHFS kernel module,
  7. Execute make install to install the compiled SHFS program and library files to system path, create symlink /sbin/mount.shfs to shfsmount, etc. You can also execute make uninstall if you want to uninstall them accordingly.

How to use SHFS to mount a remote folder or filesystem as Linux network drive?

To mount or map /tmp folder at walkernews host (via walker Linux login ID) as the local Linux network drive, execute

shfsmount walker@walkernews:/tmp /mnt/shfs

To create persistent Linux network drive with SHFS, execute

shfsmount --persistent walker@walkernews:/tmp /mnt/shfs

To preserve UID/GID of remote file creation:

shfsmount root@walkernews /mnt/shfs -o preserve,rmode=755

To display Linux kernel debugging output (verbose mode):

shfsmount -vvv walker@walkernews:/tmp /mnt/shfs

P/S: Visit official site for more SHFS installation or usage guide.

Custom Search

  1. How To Mount And Read CD ISO Image In Linux – Walker News 19-08-07@23:29

    […] just mount the network share first before mounting the CD ISO image – refers to earlier post on [ How to mount or map a network drive in Linux? […]

  2. How To Create An ISO Image Of Directory / Filesystem In Linux – Walker News 06-07-08@14:28

    […] few thousands of tiny files, either to transfer it over the network (via scp command, ftp protocol, shfs system, samba file sharing, etc) or copy between local filesystem, as there is less overheat of […]

2018  •  Privacy Policy