Let’s consider the following scenario: You have 3 hard disks (or partitions) – 100Gb, 100Gb, and 64Gb respectively, and you have a huge media library (videos and audios) of, say, 180GB. It is obvious that all your media files won’t be able to fit into one hard disk/partition, and you have to split them up to store them in different locations. While this is a no-brainer, you will have a hard time managing your files, as all of them are now scattered all over the place.
There are a few solutions. You can get a new and bigger hard drive to house your media content, but that means spending money, and you are not making good use of your existing storage space. Another solution is to set up RAID so that files can be spread evenly across the various disks, but the lack of redundancy could be a cause for concern.
mhddfs is a FUSE filesystem module that allows you to combine several partitions (or hard disks) into one virtual drive. So instead of handling three different partitions and wondering where you keep your files, you can now see all your files in one single virtual drive.
In Debian, Ubuntu or any of their derivatives, you can install
mhddfs with the command
sudo apt-get install mhddfs
In a Yum-based distro, such as Redhat, CentOS or Fedora, you can install it with the command
yum install mhddfs
Setting up mhddfs
First, check the partition setup in your system. Run the following command in the terminal:
You should see the various partitions mounted in your system. Take note of their mount points.
From the image above, you can see that I have three partitions of 19Gb, 17Gb and 12Gb.
Next, create a new mount point to hold the virtual storage.
sudo mkdir /mnt/virtual
And lastly, mount mhddfs.
mhddfs /,/external1,/external2 /mnt/virtual -0 allow_other
Note: don’t use this command blindly. You have to change the mount point to adapt to your system’s setup.
-o allow_other flag allows other users to access this virtual drive.
mhddfs: move size limit 4294967296 bytes means that if a partition contains less than 4294967296 bytes (which is 4Gb) of space, the new files will be saved to the next partition with more than 4Gb. If all the partitions have less than 4Gb, then the one with the most free space will be chosen.
Lastly, do a check on the mounted partition again.
You can now see a newly created mount point with a combined storage space of the other hard drives.
Run mhddfs on every boot
To set up mhddfs to run on every boot, we simply edit the
fstab file to mount it every time we start the computer.
fstab file in the terminal,
sudo nano /etc/fstab
and copy and paste the following lines (using “Ctrl + Shift + v”) to the end of the file.
mhddfs# /, /external1, /external2 /mnt/virtual fuse defaults,allow_other 0 0
Remember to change the file path and mount points to adapt to your computer’s settings.
Press “Ctrl + o” to save the file and “Ctrl + x” to exit.
If you want to troubleshoot your system, you can easily unmount mhddfs with the following command:
sudo umount /mnt/virtual
How to grow mhddfs
If you have installed a new hard disk and want to include it in mhddfs, here are the steps.
1. Unmount mhddfs.
2. Remount mhddfs with the new hard disk’s mount point in the list.
3. Open the
/etc/fstab file and edit the mhddfs entry.
You can follow the same steps to remove partitions from the mhddfs list, too.
mhddfs has made it really simple for you to combine various hard disks into a single storage.The best thing is that it is easy to set up and doesn’t damage your filesystem. It doesn’t require you to reformat your hard disk either. Do try it out, and let us know how you do with it.
Image credit: 500 GB hard drives
Our latest tutorials delivered straight to your inbox