Wednesday 07, September 2011

Experimenting with Aufs

I'm experimenting with aufs these days. The thing is I've started to have storage problems, regarding space constrains, with my old i386-amd desktop I use as a seedbox. It has an old sata 1.0 bus with only two connectors providing two 160GB sata HDs and one 40GB ide. As my hungry for FLAC music and HD content started to grow space started to become an issue.

Managing different storage locations started to become daunting as well. Using deluge as my torrent daemon didn't help. First I tried with labels, organizing everything in different paths by tracker but computers do that work better then me. In my head the two options were (a) to fiddle with deluge plugins or (b) obtain a larger storage for my files. Every time I thought on the latter the idea was a way to mount a vfs clustering all those HDs providing one huge storage space unified.

So, in the office a college asked me if I new something about unionfs (to debug a clients solution) and I said no, but immediately I though that it could provide me what I needed for (b). After some reading I decided to use aufs. I should say that I don't known exactly what are the differences between aufs and unionfs; the choice was made on the advertisement made in the aufs homepage.

Aufs (Unionfs AFAIK) provide different paths (known as "branches") in a single mount point. You can setup policies for branch access, writing and priorities, so when you write to the aufs vfs you can control how things will happen under the hood. All directories in branches will then be merged (this is very useful for LiveCDs attached to a usb flash). As my seedbox should boot everything smoothly everything should be mounted automatically. As for policies all branches should have write access and the branch with most space available should be chosen first to create new files. Here's my /etc/fstab:

# Entry for the aufs for deluged:
none /home/deluged/torrents aufs \
  br=/home/deluged/torrents1=rw:/home/deluged/torrents2=rw\
  :/home/deluged/torrents3=rw,create=mfs 0 0

(Mind the '\' for readability.)

Each torrentsN is a mount point for the available HDs. The create option selects a branch which has most free space for writing. /home/deluged/torrents then is my default path to store torrent files.

The result until now is great, and I couldn't be more happy. I don't have any data on performance impacts but deluge is not complaining about space even my first mount point (torrents1) has currently only 234MB of free space. The next step is to provide /home/deluged/torrents as a NFS mount point so I can access my torrents file easily.

I'd like to know if that is a coherent solution to my problem, and even if there is a better solution for this. I wonder if there is a VFS that will provide a single partition merging different devices (i.e. instead of merging directories merge blocks in different devices) -- that would be awesome -- but on the other hand would oblige me to always have all HDS available to access my files.