NOTE

Linux AUFS

AUFS implements union mounting on Linux to combine multiple directory layers. These notes introduce it through the background of UnionFS.

Operating Systems / LinuxCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. History of Linux AUFS

Because UnionFS had poor reliability and performance, AUFS is effectively a rewrite of UnionFS.

2. What Is Linux AUFS?

Advanced multi-layered unification filesystem is an implementation of union mount for the Linux filesystem. A union mount is a method of combining multiple directories into one directory. Externally, this directory appears to contain the contents of all the directories.

3. Why Linux AUFS Is Needed

4. How to Use Linux AUFS

  1. Create directories and files
    mkdir aufs
    mkdir aufs/mnt
    mkdir aufs/container-layer
    echo "I am container layer" > aufs/container-layer/container-layer.txt
    mkdir aufs/{image-layer1,image-layer2,image-layer3}
    echo "I am image layer 1" > aufs/image-layer1/image-layer1.txt
    echo "I am image layer 2" > aufs/image-layer2/image-layer2.txt
    echo "I am image layer 3" > aufs/image-layer3/image-layer3.txt
  2. Mount as AUFS
    cd aufs
    sudo mount -t aufs -o dirs=./container-layer:./image-layer1:./image-layer2:./image-layer3 none ./mnt
  3. View the contents of the mounted directory
    tree mnt
  4. Modify the contents of a file under mnt
    echo "I changed mnt/image-layer2.txt" >> mnt/image-layer2.txt
  5. View the file contents under mnt and under image-layer2
    # changed
    cat mnt/image-layer2.txt
    # unchanged
    cat image-layer2/image-layer2.txt
  6. View the container-layer directory
    tree container-layer

5. How Linux AUFS Works

5.1. Copy-on-Write

When multiple owners use the same resource, there is no need to create a separate copy until it is modified. The owners share the resource. When any owner wants to modify the resource, a new copy is created for that owner to modify. The modified resource becomes that owner’s private resource. By sharing resources in this way, the cost of copying identical resources can be significantly reduced, but doing so also adds some overhead when the resource is modified.

6. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub