What? How? Why? Requirements Installation Usage

SHFS installation guide

Warning: This is beta quality code. It was not tested on SMP machine. Backup data before playing with it!

What?

SHFS stays for SHell File System. It is a simple Linux kernel module partially based on Florin Malita's ftpfs. Using this module, you can connect remote filesystems into your local filesystem tree.

$ shfsmount user@host /local/path
user@host password:
$ cd /local/path

With some quirks you can even use automounter and access your remote data just like the local ones. Imagine:

# ssh-agent
# cd /shfs/user%host
# ls -l
drwx--x--x    7 user     group        4096 May 17 15:26 WWW
drwx------    5 user     group        4096 May 29 18:27 bin
drwx------    3 user     group        4096 May 31 16:11 mail
drwxr-xr-x    5 user     group        4096 Apr 13 12:02 src

Just like NFS or ftpfs, but in a secure and wide-compatible way.

How?

Why?

To say the truth, it is our work for Operating Systems course at Charles University. It is just hack, but works, at least for me :-).

Requirements

Installation

Installation should be straightforward. First, download sources (shfs-x.xx.tgz).

  1. unpack the tarball
    # tar -xzvf shfs-x.xx.tgz
    
  2. Check shfs/Makefile and the include path (-I switch). It should contain path to include directory of your current kernel.
  3. Important: check that your compiler is the same as used for compiling your kernel:
    # gcc --version
    2.96
    # cat /proc/version
    Linux version 2.4.18 (root@host) (gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98))
    
    If these versions differ, check for your configuration, how to call the kernel compiler (e.g. gcc-3.2). You will have to pass this to make (make CC=gcc-3.2).
  4. make kernel module and shfsmount
    # make
    
    or (if you must spcify the compiler):
    # make CC=compiler
    
  5. insert kernel module
    # insmod shfs/shfs.o
    
  6. mount remote filesystem, and test it
    # shfsmount/shfsmount user@hostname /mnt
    
  7. install shfs
    # make install
    
  8. if you don't like it [unlikely ;-)], wipe it out
    # make uninstall
    
  9. You can even make (debian/rpm) package and install it.
    # make deb
    # dpkg -i ../shfs*.deb
    
    or
    # make rpm
    # rpm -ivh ../shfs*.rpm
    

Usage

The shfsmount command has a number of options. You have seen the simplest form in the Installation section above.
General usage is:

shfsmount [options] [user@]hostname[:port][/root] mount_point -o mount_options

Options:
-rUse rsh instead of ssh.
-O option Specify ssh (rsh) option (e.g. -O "-c 3des" == ssh -c 3des).
-uExecute ssh as this user (root only)
-vPrint version of shfsmount.
userLog in using this user name.
hostname Specify remote host
portUse this port to log in (ssh).
rootRemote directory to became root of the new mounted tree.

Mount options
nocacheDisable read-ahead and write-back cache.
genericDo not use optimised shell command set.
preservePreserve uid/gid (root only).
uid=idOwner of all files/dirs on mounted filesystem (root only).
gid=idGroup of all files/dirs on mounted filesystem (root only).
rmode=mode Root dir mode.
suid, devsee mount(8) (root only)
ro, rw, nosuid, nodev, exec, noexecsee mount(8)

Shfsmount was designed to have the same interface as the mount command. make install should have created symlink /sbin/mount.shfs -> shfsmount so you will be able to call

# mount -t shfs user@host /mnt
exactly as with other filesystems. You can even use automounter to connect to server automatically (think about using ssh keys).

If you would like all users to be able to mount remote dirs using shfs, set suid bit on /usr/bin/shfsmount and /usr/bin/shfsumount. Security checks are similar to smbmount.

Generic shell file operations (currently used on all systems except Linux) use very slow write command. For more info on this topic see internal docs.

--
<qiq@atrey.karlin.mff.cuni.cz>