21 Mar 2005 mchirico   » (Journeyer)

Unionfs - Very Impressive.

When this Linux Journal article first appeared, Unionfs wouldn't compile on the 2.6 kernel. But now, as long as you're using a 2.6.9+ kernel, it works like a charm.

I can't emphasize it enough; take a close look at the last part of that linux journal article. You've probably heard that KNOPPIX is using Unionfs; but, the real power is putting it in your own hands. Especially, if you create your own live Linux cds.


QUICK INSTALL

Fedora Core 3 currently uses the 2.6.10 kernel, so you won't have any trouble with this distro. Or, if you don't want to mess with your kernel, download and burn my iso - more on this approach later; but, lets just get started on your local system

Step 1: Download and Compile

Download the latest tar.gz from ftp://ftp.fsl.cs.sunysb.edu/pub/unionfs/

   # tar -xzf unionfs-1.0.9.tar.gz
   # cd unionfs-1.0.9
   # make

The above steps should compile, leaving you with unionfs.ko

Step 2: Load unionfs.ko

This is the quick way of load the module, assuming you have ``su -'' to root.

   # insmod unionfs.ko

You can check that is loaded correctly by executing the following command:

   # cat /proc/modules |grep 'unionfs'
unionfs 1021460 0 - Live 0xf8ee9000

By the way, if you need to unload the module, the command is ``rmmod unionfs.ko''.

ROAD TESTING

If you read the Linux Journal article, you'll see that it creates a ``union'' of two directories. So you can have an NFS mounted home directory combined with local home. Everything shows up under one directory. It doesn't matter if there are duplicates.

I have an NFS mounted home ``/home2/chirico'' that I combine with the local home ``/home/chirico''.

    # mount -t unionfs -o dirs=/home/chirico:/home2/chirico none /home/chirico

The union of the two directories show up under ``/home/chirico''; and if there are duplicate filenames, then, the file in ``/home/chirico'' will take priority.

Unionfs with CD

I have a live Linux CD, which is a base install to get Linux running in RAM. But, it has Unionfs so when it boots, I can mount the ``/etc'', ``/lib'', ``/bin'' and even ``/dev'' directories from the hard drive of the computer. See Create a Custom Live Linux CD (f.2) in the FAQ section. By the way, if you unionfs ``/dev'' you get additional access to devices.

OK, so what. Well, my goal was to create a rescue cd so that the system could be up and running in the time it takes to reboot. Ideally swap in a second computer without a HD and boot from the CD. Assuming the critical files exist as an NFS mount, on another server they can be NFS/unionfs mounted. Now, as the other files are restored from tape, they too can be unionfs mounted. Since unionfs can also parse out changes to these directories, once the initial computer gets fix, these changes can be merged into a single directory.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!