FUSE: Filesystem in Userspace

According to wikipedia, a filesystem is:

is a method for storing and organizing computer files and the data they contain to make it easy to find and access them.

It is the filesystem which provides us the abstraction of folders, directories and sub-directories that we use to store files on a computer. Infact, it is the filesystem only which lets us store and retrieve any data that we store in a computer.

Filesystems are usually a part of the kernel, the heart of the operating system and the code runs in a privileged mode known as kernel mode which means that only the operating system has access to that code. That is also the reason why developing a real filesystem is usually the domain of highly talented kernel developers.

FUSE changes all that. FUSE, which stands for “Filesystem in USErspace”, provides an API (application programming interface) for anyone to create their own filesystem, which runs like a normal user program. If all this is confusing you, don’t worry, cause you don’t really have to worry about these details.

How is FUSE useful for you ?

Like I said, FUSE provides an interface for anyone to create a filesystem without resorting to nifty trickery in the kernel world. This has led to a proliferation of a large number of rather useful filesystem hacks. Filesystems which let you view compressed archives, let you make backups or encrypt your files.

Let’s look at how to setup FUSE on an Ubuntu 8.04 based system and use that to mount an encrypted filesystem using sshfs. FUSE is a part of the Ubuntu ‘Hardy Heron’ kernel and the module should be loaded when the system boots up. Check for it using the lsmod command:

sharninder@blr-skhera:~$ lsmod|grep fuse
fuse 50708 3

Now, you should install the FUSE utilities package and the library package.

$ sudo apt-get install fuse-utils libfuse2

Now, you can go ahead and install sshfs using the following command:

sharninder@blr-skhera:~$ sudo apt-get install sshfs

You should now have a working installation of sshfs and you’re ready to mount a remote filesystem over an encrypted channel. Mounting an sshfs partition is as simple as:

sharninder@blr-skhera:~$ sshfs testuser@testserver:/home/testuser MP
testuser@testserver’s password:
sharninder@blr-skhera:~$ cd MP
sharninder@blr-skhera:~/MP$ ls
etc mail public_html tmp

The above command will mount the ‘/home/testuser’ directory from the testserver to the ‘MP’ mount point on the local system. The entire communication between the client and the server will be encrypted and the user testuser will be used to communicate with the server. This can be a handy way to access frequently used servers and all regular Unix commands like cp, rm, mv will work on the mount point as if it is a local directory.

To unmount the filesystem, use the following command:

$ fusermount -u MP

Where MP is the mount point.

Now, that you have used the sshfs module you’re all set to explore the countless other modules that have been developed for FUSE. Try playing with flickrfs, fuseiso, fusedav or fusesmb and let us know how it goes.

Leave a Reply

Your email address will not be published. Required fields are marked *