Let’s say you have three disks but you wish to share with Samba or NFS clients.

Of course you could just mount the disks on three separate mount points and export those. Or you could mount the three disks on three mount points inside the same directory and export the parent directory. The problem with both solutions is you have to “balance” the data among the disks – and it will make navigating your TViX, WDTV or Popcorn more annoying.

You could use RAID or LVM to handle all this for you. But. What if you already have data on the disks? What happens if one of the disks dies? With RAID0 or LVM your data is gone.

Luckily you can have the best of both worlds: mhddfs

mhddfs is a FUSE plugin that combines data from several directories and present it in one directory. The only downside is that you do not know (or control) where a file is created. Let’s say you combine /dir1, /dir2 and /dir3 under /virtual. Previously you had /dir1/my_content. This is now /virtual/my_content. If you write a file to /virtual/my_content it will not necessarily end up in /dir1/my_content. This also mean you can not predict what data is lost if you lose a disk.

The plugin is available in Ubuntu

$ sudo apt-get install mhddfs

Using it is pretty simple

$ sudo mkdir /export/hest
$ sudo mhddfs /dir1,dir2,dir3 /export/hest

mhddfs: directory '/dir1' added to list
mhddfs: directory '/dir2' added to list
mhddfs: directory '/dir3' added to list
mhddfs: mount to: /export/hest
mhddfs: move size limit 4294967296 bytes

The “move size limit” deserves an explanation:

if free space size threshold if a drive has the free space less than the threshold specifed then another drive will be choosen while creating a new file. If all the drives have free space less than the threshold specified then a drive containing most free space will be choosen.

Default value is 4G, minimum value is 100M.

Now you have the combined space of all three disks

/dir1;/dir2;/dir3
                      589G  329G  260G  56% /export/hest

To mount the combined directory during boot, at this to /etc/fstab:

mhddfs#/dir1,/dir2,/dir3 /export/hest fuse defaults,allow_other 0 0

You can export the combined directory using NFS or Samba. If you export the combined directory using NFS you need to add the fsid option in /etc/exports

/export/hest 192.168.1.0/24(fsid=2,ro,sync,crossmnt,no_subtree_check,insecure)