
Aufs -- Another Unionfs
Junjiro Okajima

# $Id: README,v 1.35 2007/02/05 01:41:47 sfjro Exp $

--------------------
0. Introduction
--------------------
Aufs was entirely re-designed and re-implemented Unionfs. After
many original ideas, approaches, improvements and implementations, it
becomes totally different from Unionfs while keeping the basic features.
Unionfs is being developed by Professor Erez Zadok at Stony Brook
University and his team.
If you don't know Unionfs, I recommend you to try and know it before
using aufs. Some terminology in aufs follows Unionfs's.

Bug reports (including my broken English), suggestions, comments
and donations are always welcome. Your bug report may help other users,
including future users. Especially the bug which doesn't follow unix/linux
filesystem's semantics is important.


--------------------
1. Features
--------------------
- unite several directories into a single virtual filesystem. The member
  directory is called as a branch.
- you can specify the permission flags to the branch, which are 'readonly',
  'readwrite' and 'whiteout-able.'
- by upper writable branch, internal copyup and whiteout, files/dirs on
  readonly branch are modifiable logically.
- dynamic branch manipulation, add, del.
- etc... see Unionfs in detail.

Also there are many enhancements in aufs, such like,,,
- safer and faster
- keep inode number by external inode number table
- keep the timestamps of file/dir in internal copyup operation
- seekable directory, supporting NFS readdir.
- support mmap(2) including /proc/PID/exe symlink, without page-copy
- whiteout is hardlinked in order to reduce the consumption of inodes
  on branch
- do not copyup, nor create a whiteout when it is unnecessary
- revert a single systemcall when an error occurs in aufs
- remount interface instead of ioctl
- maintain /etc/mtab by an external shell script, /sbin/mount.aufs.
- loopback mounted filesystem as a branch
- kernel thread for removing the dir who has a plenty of whiteouts
- support copyup sparse file (a file which has a 'hole' in it)
- default permission flags for branches
- selectable permission flags for ro branch, whether whiteout can
  exist or not
- and more... see aufs manual in detail

Aufs is in still development stage, especially,,,
- pseudo hardlink (hardlink over branches)
- allow a direct access manually to a file on branch, e.g. bypassing aufs.
  including NFS or remote filesystem branch.
- support 'security' model
- remount option copy/move between two branches, selecting writable branch
  policy.
- O_DIRECT (unnecessary?)
- export via NFS (unnecessary?)
- light version, without branch manipulation.
- SMP, because I don't have such machine.
- xattr, acl
- and documentation


--------------------
2. Download
--------------------
CVS tree is in aufs project of SourceForge.
Here is simple instructions to get aufs source files. It is recommended to
refer to the document about CVS on SourceForge.
	$ mkdir aufs.wcvs
	$ cd aufs.wcvs
	$ cvs -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs login
	(CVS password is empty)
	$ cvs -z3 -d:pserver:anonymous@aufs.cvs.sourceforge.net:/cvsroot/aufs co aufs

In order to update files after first checkout.
	$ cd aufs.wcvs/aufs
	$ cvs update

In order to see what the difference between two versions (two dates) is,
	$ cd aufs.wcvs/aufs
	$ cvs diff -D20061212 -D20061219

I always try putting the stable version in CVS, so you can try CVS
instead of SourceForge File Release. And every changes are summarized
and reported to aufs-users at lists.sourceforge.net ML. It is recommended to
join this ML.


--------------------
3. Contact
--------------------
When you have any problems or strange behaviour in aufs, please let me
know with,,,
- /proc/mounts (instead of the output of mount(8))
- linux kernel version
- AUFS_VERSION (defined in include/linux/aufs_type.h)
- configuration (define/undefine CONFIG_AUFS_xxx, or plain local.mk is
  used or not)
- phenomenon
- actual operation, reproducible one is better
- mailto: aufs-users at lists.sourceforge.net

Usually, I don't watch the Public Areas(Bugs, Support Requests, Patches,
Feature Requests) on SourceForge. Please join and write to aufs-users ML.


--------------------
4. Configuration and Compilation
--------------------
Aufs is being developed and tested on linux-2.6.16 and later.

o CONFIG_DEBUG_PROVE_LOCKING (in linux kernel)
If you enable CONFIG_DEBUG_PROVE_LOCKING in your linux kernel, you
will be warned at aufs compile time. And at aufs run time, some
harmless warnings will be issued, and CONFIG_DEBUG_PROVE_LOCKING will
be disabled automatically.
See detail in aufs.5.

o CONFIG_AUFS_HINOTIFY
This is valid for linux-2.6.18 and later.
If you want to modify files on branches directly, e.g. bypassing aufs, and want
aufs to detect the changes of them fully, enable this configuration and use
'udba=inotify' mount option.
See detail in aufs.5.

o CONFIG_AUFS_KSIZE_PATCH
This patch is valid for linux-2.6.16 and later.
Aufs sometimes needs to 'realloc' memory. In linux kernel, people usually
writes the sequence which is alloc/copy/free memory. If 'ksize' kernel
internal function is exported to modules, aufs can omit alloc and free in the
sequence and runs efficiently in some cases.
Here is a patch for it, called ./ksize.patch which only exports the function.
It is recommended to apply this patch to your kernel and enable this
configuration.
If you don't want to modify/recompile your kernel, you can use aufs without
this patch and leave this configuration as disabled.
When you link aufs to your kernel statically, i.e. CONFIG_AUFS=y instead of
'=m', you don't need ./ksize.patch.

o CONFIG_AUFS_LHASH_PATCH
This patch is valid for linux-2.6.19 and later.
If you use mounted NFS as an aufs branch filesystem in linux-2.6.19 or later,
then you need to apply the patch './lhash.patch' to you kernel source, and
enable this configuration. This patch does nothing but exports the kernel
internal function __lookup_hash().
If your kernel is before 2.6.19 or you don't use NFS as a branch, you don't
need this patch.

Some users contributed the patches against fs/Kconfig and fs/Makefile. Thank
you very much. While they are not included in CVS tree, they may help you. You
can find them at,
- 'Patches' on SourceForge aufs public place, while I don't usually go there.
  and post on 23 Oct 2006 to aufs-users@lists.sourceforge.net ML.
- post on 12 Jan 2007 to the ML.

Currently these configurations are written in ./local.mk, ./local.mk will work
for you in most cases.
	$ make -f local.mk
The local.mk searches your kernel build path by
	KDIR = /lib/modules/$(shell uname -r)/build
If you are cross-compiling the aufs module, try
	$ make KDIR=/your/kernel/build/path -f local.mk


--------------------
5. Usage
--------------------
	(after 'make')
	$ man -l ./aufs.5
	# install -m 500 -p mount.aufs umount.aufs auplink aulchown /sbin (recommended)
	# insmod ./aufs.ko
	$ mkdir /tmp/rw /tmp/aufs
	# mount -t aufs -o dirs=/tmp/rw:${HOME}=ro none /tmp/aufs

Here is another example.

	# mount -t aufs -o br:/tmp/rw:${HOME}=ro none /tmp/aufs
	or
	# mount -t aufs -o br:/tmp/rw none /tmp/aufs
	# mount -o remount,append:${HOME}=ro /tmp/aufs

If you disable CONFIG_AUFS_COMPAT in your configuration, you can remove the
default branch permission '=ro.'

	# mount -t aufs -o br:/tmp/rw:${HOME} none /tmp/aufs

Then, you can see whole tree of your home dir through /tmp/aufs. If
you modify a file under /tmp/aufs, the one on your home directory is
not affected, but the same named file will be newly created under
/tmp/rw. And all of your modification to the file will be applied to
the one under /tmp/rw. This is called Copy on Write (COW) method.
Aufs mount options are described in the generated ./aufs.5.
Additionally, there is a sample usage of aufs which is a diskless system with
network booting. See ./sample in detail.


--------------------
6.
--------------------
If you are an experienced user, no explanation is needed. Aufs is
just a linux filesystem module. take a glance at ./local.mk,
aufs.in.5, and Unionfs.


Enjoy!

# Local variables: ;
# mode: text;
# End: ;
