Suppose you have several drives of different geometries which you would like to join together into a large storage pool. There are several options available:
A different option is to use mhddfs which is a filesystem in user space (fuse) that can merge several large filesystems into a single large filesystem. Since mhddfs is a filesystem in user-space, it does not even require root privileges and also does not require the drives to be partitioned using the same filesystem.
Moreover, the advantage is that if one drive fails, then only the data on that drive will be lost while the other drives will be mountable, readable and contain data you can access.
In order to use mhddfs, it must be installed. On a Debian Linux system, this can be achieved with:
aptitude install mhddfs
which is all that is required.
The example setup presented here consists of two drives:
/dev/sdb1
of 1TB/dev/sdc1
of 500MB
In order to merge these two drives together, we first need a filesystem. In our case, we use ext4
for both drives - although we could have picked something different for each, and issue the commands:
mkfs.ext4 -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,dir_index -i 4194304 /dev/sdb1
respectively:
mkfs.ext4 -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,dir_index -i 4194304 /dev/sdc1
in order to format the /dev/sdb1
, respectively /dev/sdc1
partitions.
Once that is accomplished, we can now issue the command:
blkid
which will list the UUIDs for each partition so we can reference them in /etc/fstab
. For example, the output of blkid
would be:
/dev/sdb1: UUID="31ced4e8-3006-4097-817e-609a4c4ca6d9" TYPE="ext4" PARTUUID="2afd8654-8d06-46da-b8f5-bed3417a6e7f" /dev/sdc1: UUID="5cede964-0992-401f-8806-d5a3586b7136" TYPE="ext4" PARTUUID="037e0077-6c03-46c4-bd8b-3749d44c34d1"
We now create mount-points for /dev/sdb1
and /dev/sdc1
:
mkdir /mnt/bag_1 mkdir /mnt/bag_2
and change /etc/fstab
to mount /dev/sdb1
, respectively /dev/sdc1
to /mnt/bag_1
, respectively /mnt/bag_2
:
UUID=31ced4e8-3006-4097-817e-609a4c4ca6d9 /mnt/bag_1 ext4 rw,noatime,nodiratime,journal_async_commit,nofail 0 0 UUID=5cede964-0992-401f-8806-d5a3586b7136 /mnt/bag_2 ext4 rw,noatime,nodiratime,journal_async_commit,nofail 0 0
and we mount them:
mount /mnt/bag_1 mount /mnt/bag_2
Now we create a mount-point where mhddfs will join the two partitions together:
mkdir /mnt/bag
and create an /etc/fstab
entry:
mhddfs#/mnt/bag_1,/mnt/bag_2 /mnt/bag fuse allow_other 0 0
Finally, we mount mhddfs:
mount /mnt/bag
If everything went alright, then you can now write to /mnt/bag
as if it were a regular filesystem and mhddfs will distribute the files to both /dev/sdb1
and /dev/sdc1
.