Wednesday, August 02, 2006
Playing with unionfs on SLES10 (s390x)
Note: The instructions below assume you have set up
sudo to enable yourself to issue commands as root.Since SLES10 comes with the 2.6.16 kernel, we're limited to unionfs-1.2 (as documented)
- Install e2fsprogs-devel and e2fsprogs-devel-32bit as provided with your SLES10 installation. If you have not done so already, you'd also need to install the version of the kernel-source rpm that matches the kernel you run, the gcc compiler, binutils, make and patch.
- Download the source and untar the file.
tar xzf unionfs-1.2.tar.gz - Get an extra patch1 and apply on your unionfs-1.2 directory
cd ~
wget href=http://www.rvdheij.nl/unionfs/unionfs-1.2-s390-patch1
cd ~/unionfs-1.2
patch -p1 -i ~/unionfs-1.2-s390-patch1 - Build the kernel module and binaries with
cd ~/unionfs-1.2
make - Install the kernel module unionfs.ko and the tools. I had some trouble the "make install" so you might want to copy the files by hand.
cd ~/unionfs-1.2
sudo cp unionfs.ko /lib/modules/`uname -r`/kernel/fs - Rebuild the module dependency map with
sudo depmod -a - Load the kernel module
sudo modprobe unionfs - Prepare some directories for testing
cd ~
mkdir old new test
cd old ; echo one > one ; echo two > two ; cd ..
cd new ; echo uno > one ; cd .. - Mount the directories
sudo mount -t unionfs none ~/test -o dirs=~/new=rw:~/old=ro
cd ~/test
ls -l
If all worked as it should, you should see both one and two files in the directory test. Display the contents of the file "one" to see that you have indeed the new one. So the two directories are merged into a union where the "new" directory takes precedence.
If you modify or remove the "one" file, things will happen actually in the ~/new directory. If you try to modify the "two" file (which is in the R/O directory ~/old) the new version of the file will be placed in the topmost R/W directory (~/new) and effectively hide the original one. If you remove the "one" file, a "white-out" entry will be placed in the ~/new directory to mask the file that still resides in the ~/old directory. You can verify this by looking in these individual directories.
Even more intriguing is to mount the union back on one of its components, like
sudo mount -t unionfs none /usr/bin -o dirs=/usr/bin:/opt/appl/bin
This makes all files in /opt/appl/bin appear like in /usr/bin (and thus avoid the need for symlinks or changes to your default search path).