HOW-TO Setup a AUFS

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
Kayot

HOW-TO Setup a AUFS

Post by Kayot »

The Command:
mount -t aufs -o br=<Source Folder Name>=rw:<Source Folder Name>=rw:<Source Folder Name>=rw:<Source Folder Name>=rw -o create=mfs -o sum none <Destination Folder Name>
Red is mounted folders
Green is how to handle new files
Blue is an empty directory that will become the storage pool
Purple is -o sum which makes it so the mount returns the total free space in the pool

How to handle new files:
tdp - Selects the highest writable branch where the parent dir exists. If the parent dir does not exist on a writable branch, then the internal copyup will happen. The policy for this copyup is always ’bottom-up.’ This is the default policy.
rr - Selects a writable branch in round robin. When you have two writable branches and creates 10 new files, 5 files will be created for each branch. mkdir(2) systemcall is an exception. When you create 10 new directories, all are created on the same branch.
mfs[:second] - Selects a writable branch which has most free space. In order to keep the performance, you can specify the duration (’second’) which makes aufs hold the index of last selected writable branch until the specified seconds expires. The first time you create something in aufs after the specified seconds expired, aufs checks the amount of free space of all writable branches by internal statfs call and the held branch index will be updated. The default value is 30 seconds.
mfsrr:low[:second] - Selects a writable branch in most-free-space mode first, and then round-robin mode. If the selected branch has less free space than the specified value ’low’ in bytes, then aufs re-tries in round-robin mode. Try an arithmetic expansion of shell which is defined by POSIX. For example, $((10 * 1024 * 1024)) for 10M. You can also specify the duration (’second’) which is equivalent to the ’mfs’ mode.
pmfs[:second] - Selects a writable branch where the parent dir exists, such as tdp mode. When the parent dir exists on multiple writable branches, aufs selects the one which has most free space, such as mfs mode.

Example:
First I need the tools.

Code: Select all

Mint@Mint /mnt $ sudo apt-get update
Mint@Mint /mnt $ sudo apt-get install aufs-tools
Make 4 mounts: I have 4 drives with the drive labels Storage1, Storage2, Storage3, and Storage4. I make 4 folders with the same name and then mount the drives by lable. I also make the pool folder where I'll mount the pool

Code: Select all

Mint@Mint /mnt $ sudo mkdir Storage1 Storage2 Storage3 Storage4 Storage
Mint@Mint /mnt $ sudo mount -L Storage1 Storage1
Mint@Mint /mnt $ sudo mount -L Storage2 Storage2
Mint@Mint /mnt $ sudo mount -L Storage3 Storage3
Mint@Mint /mnt $ sudo mount -L Storage4 Storage4
Now I mount an aufs using pmfs as I want to keep my music on one disk, and I have my movies on two disks. I don't want them scattered about should I want to split them apart later.

Code: Select all

mount -t aufs -o br=Storage1=rw:Storage2=rw:Storage3=rw:Storage4=rw -o create=pmfs -o sum none Storage
Now wasn't that fun?
Corvalis

Re: HOW-TO Setup a AUFS

Post by Corvalis »

I did not know what AUFS was at first. Quick link for others who are curious: https://en.wikipedia.org/wiki/Union_mount
Post Reply

Return to “Tutorials”