Install MHDDFS on Arch Linux

Install MHDDFS Fuse based Virtual Storage Pool on Arch Linux

Mhddfs allows to pool physical drive mount points or any other directories into a single virtual directory. It is fuse based so performance does take a hit so does the CPU resource usage. It does however work well otherwise and is easy to set up. It still offer sufficient performance for a home server use.

 

MHDDFS is no longer in development and there are better union filesystems available. An excellent alternative is Mergerfs which is in active development, is more stable, faster and feature rich.

 

Install MHDDFS

Install Packer on Arch Linux or install Yaourt on Arch Linux or another package wrapper.

 

Install with packer.

packer -S mhddfs

 

Setup MHDDFS Mount Points

Mount Filesystem Partitions in Arch Linux

 

Create a directory that will be used as a mount point for the virtual pool.

sudo mkdir /mnt/virtual

 

If mhddfs fails to mount at boot or get’s unmounted for any reason the mount point still remains. This means that any application will still see a volume but instead of the pooled volume it will be an ordinary directory on the system. This means that data can be written to this directory possibly filling the system drive. This unwanted behaviour can be prevented by allowing only root access to the mount point.

 

Set the mount point ownership to root user and group.

sudo chown root:root /mnt/virtual

 

Set the mount point permissions to allow full access to the owner and group.

sudo chmod 770 /mnt/virtual

 

Set immutable flag on the mount point to prevent accidental changes to ownership or permissions.

sudo chattr +i /mnt/virtual

When set immutable flag will prevent changing permissions or ownership by anyone including root. The flag can be removed with -i option.

 

Mount MHDDFS manually

Mount mhddfs volume with desired options.

sudo mhddfs /mnt/disk1,/mnt/disk2,/mnt/disk3,/mnt/disk4,/mnt/disk5 /mnt/virtual -o allow_other -o mlimit=20G

To allow access to users other than the one that mounted mhddfs volume use allow_other option. Optionally set a minimum limit to prevent a physical hard drive from filling up beyond a certain point. Minimum limit value can be specified in megabytes mM, kilobytes kK or gigabytes gG with mlimit option. This limit will only be exceeded if all directories reach this limit in which case the directory with the most free space will be used. This means the limit can be set to a very low value to spread data on all drives. If you want directories to fill up before moving on to the next drive the default of 4GB is sufficient to prevent severe performance loss. The minimum allowed value is 100M. For optimal performance it’s a good idea to leave 5% to 10% of the storage device free.

 

Mount MHDDFS with fstab

Open the file systems table file.

sudo nano /etc/fstab

 

Add the mount command at the end of the file.

mhddfs#/mnt/disk1,/mnt/disk2,/mnt/disk3,/mnt/disk4,/mnt/disk5 /mnt/virtual fuse allow_other,mlimit=50G 0 0

 

Mount all entries listed in fstab.

sudo mount -a

 

Mount MHDDFS with Systemd

The advantage of mounting with systemd service is that it is much easier to remember systemd start command than it is to remember the full mhddfs mount command. It is also a good practice to mount mhddfs after physical disks in fstab have been mounted. Mhddfs package does not come with a systemd script by default so a custom script needs to be created.

 

Create the mount.

sudo nano /etc/systemd/system/mnt-virtual.mount

Note that the name of the systemd mount file has to match the Where =   field. Slashes ( / ) in the path are replaced by dashes ( ). So /mnt/virtual becomes mnt-virtual. Non matching name will result in a failed start of the script with error “Where= setting doesn’t match unit name. Refusing.“.

 

Copy the script and save.

[Unit]
Description = Mount mhddfs virtual volume
Requires = mnt-disk1.mount
Requires = mnt-disk2.mount
Requires = mnt-disk3.mount
Requires = mnt-disk4.mount
Requires = mnt-disk5.mount
Requires = mnt-disk6.mount
Requires = mnt-disk7.mount
Requires = mnt-disk8.mount

After = mnt-disk1.mount
After = mnt-disk2.mount
After = mnt-diks3.mount
After = mnt-diks4.mount
After = mnt-diks5.mount
After = mnt-diks6.mount
After = mnt-diks7.mount
After = mnt-diks8.mount
After = mnt-diks9.mount
After = mnt-diks10.mount

[Mount]
What = mhddfs#/mnt/disk1,/mnt/disk2,/mnt/disk3,/mnt/disk4,/mnt/disk5,/mnt/disk6,/mnt/disk7,/mnt/disk8
Where = /mnt/virtual
Type = fuse
Options = allow_other,mlimit=100G 0 0

[Install]
WantedBy = multi-user.target

 

Run MHDDFS with Systemd

Start the service with systemd.

sudo systemctl start mnt-virtual.mount

 

Enable the service to run on boot with systemd.

sudo systemctl enable mnt-virtual.mount

 

MHDDFS Bugs & Issues

Like everything Mhddfs has it’s own set of advantages and disadvantages. Since it is fuse based and therefore runs at user level as opposed to kernel level it suffers from performance issues. Besides increased CPU utilization and decreased total disk throughput it can have other issues. There is a bug in mhddfs 0.1.39 that causes the pooled volume to drop out with an error – “Transport endpoint is not connected“. To solve this either downgrade to a earlier version or simply live with it and reboot on the infrequent occasions when this happens.

Software relying on directory modified date attribute such as Kodi, Plex and Subsonic can have issues since mdate attribute displayed can be inconsistent. Unlike with Mergerfs there is no option to correct this. This problem can sometimes be worked around in specific applications. In Kodi for example fast hash feature can be disabled in advance settings configuration file which will ignore mdate.