How to Merge Multiple Linux Disks into a Single Mount Point Using UnionFS, mhddfs or LVM


1 views

When managing storage servers, we often face situations where we need to combine multiple physical disks into a single logical directory. The traditional approach of mounting each disk separately leads to manual file distribution and inefficient storage utilization.

Linux offers several methods to achieve this unified storage view:

  • UnionFS: A stackable unification filesystem
  • mhddfs: A FUSE-based solution
  • LVM: The Linux Logical Volume Manager
  • OverlayFS: Modern kernel-based solution

For quick implementation, mhddfs provides an excellent balance of simplicity and functionality:

# Install mhddfs
sudo apt-get install mhddfs

# Create mount point
sudo mkdir /storeall

# Mount combined storage
sudo mhddfs /store1,/store2,/store3,/store4 /storeall -o allow_other

# Verify
df -h | grep storeall

For production environments, LVM offers better reliability and features:

# Create physical volumes
sudo pvcreate /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2

# Create volume group
sudo vgcreate store_vg /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2

# Create logical volume
sudo lvcreate -l 100%FREE -n store_combined store_vg

# Format and mount
sudo mkfs.ext4 /dev/store_vg/store_combined
sudo mkdir /storeall
sudo mount /dev/store_vg/store_combined /storeall

Each method has different performance characteristics:

Method Performance Reliability
mhddfs Medium Good
UnionFS Low-Medium Medium
LVM High Excellent

For persistent mounts, add to /etc/fstab:

# For mhddfs
mhddfs#/store1,/store2,/store3,/store4 /storeall fuse allow_other 0 0

# For LVM
/dev/store_vg/store_combined /storeall ext4 defaults 0 2

If you only need read access, OverlayFS is built into modern kernels:

sudo mount -t overlay overlay -o lowerdir=/store1:/store2:/store3:/store4 /storeall
  • Permission problems with FUSE solutions (use allow_other option)
  • LVM volume group detection issues (run vgscan)
  • Filesystem inconsistencies after crashes (always use journaling filesystems)

When managing storage servers, we often face situations where data spans across multiple physical disks. Traditional mounting creates separate directories like:

/dev/sda1 → /store1 (1TB)
/dev/sda2 → /store2 (2TB) 
/dev/sdb1 → /store3 (2TB)
/dev/sdb2 → /store4 (2TB)

Linux offers several ways to merge storage:

Option 1: MergerFS (Recommended)

MergerFS is a modern union filesystem designed specifically for pooling storage:

sudo apt install mergerfs  # Debian/Ubuntu
sudo dnf install mergerfs  # RHEL/Fedora

# Basic mounting:
mergerfs -o defaults,allow_other /store1:/store2:/store3:/store4 /storeall

# Advanced options for better performance:
mergerfs -o defaults,allow_other,category.create=ff,minfreespace=20G /store1:/store2:/store3:/store4 /storeall

Option 2: LVM (Logical Volume Manager)

For raw capacity merging without filesystem awareness:

# Create physical volumes
sudo pvcreate /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2

# Create volume group
sudo vgcreate storage_vg /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2

# Create logical volume
sudo lvcreate -l 100%FREE -n storage_lv storage_vg

# Format and mount
sudo mkfs.ext4 /dev/storage_vg/storage_lv
sudo mount /dev/storage_vg/storage_lv /storeall

When choosing between solutions:

  • MergerFS: Preserves individual disks, easy to expand, supports different filesystems
  • LVM: Better performance, single filesystem, but more complex expansion

For rsync operations, both solutions will work, but MergerFS gives more flexibility when dealing with disk failures or expansions.