Combining multiple drives on Linux

with the magic of mergerfs

  •  1 min  •  

mergerfs is a very useful tool where you have multiple, small, drives of varying sizes and want to use them as a single composite drive.

Installation

Get the latest release off GitHub and install it.

Configuration

Mount your various drives. For instance, if you have Drives A, B, and C, your /etc/fstab might look like this:

/dev/sda  /media/Drive-A ntfs    defaults,uid=huey,file_mode=0777,dir_mode=0777  0       0
/dev/sdb  /media/Drive-B  ntfs    defaults,uid=huey,file_mode=0777,dir_mode=0777  0       0
/dev/sdc  /media/Drive-C  ntfs    defaults,uid=huey,file_mode=0777,dir_mode=0777  0       0

Add a mergerfs mount line to your /etc/fstab to create a composite drive:

/media/Drive-A:/media/Drive-B:/media/Drive-C  /media/CompositeDrive fuse.mergerfs allow_other,direct_io,use_ino,category.create=lfs,moveonenospc=true,minfreespace=20G,fsname=yourCompositeDrive

Behind the Abstraction

It's all FUSE so any kind of drive works — you can mix network drives with physical SATA drives, and possibly even your Dropbox or Google Drive mounted as a FUSE filesystem.

You can specify FUSE function policies in the mergerfs line in /etc/fstab to configure various behaviour. By default, files are created in accordance with the epmfs (existing path, most free space) policy, meaning they are created in the drive where the parent directory already exists (if applicable), otherwise on the drive with the most free space at the time. You can set func.category.action=eplfs, for instance, to create files on the drive with the least free space instead.

Each file and directory exists on a single drive and is not spread out across the various drives. mergerfs functions by creating a union of the filesystems within the various drives, and is akin to creating symlinks between the various drive and the composite virtual drive. This means that if one drive fails, only the files and directories stored on that drive are lost. The overall file structure is unaffected.