1

Similar question has already been asked on ServerFault but I have a slight difference that might create issues if I follow already answered question's solution, therefore I must make sure.

The idea is for the /var/www/html/ directory to show files that are present in /mnt/a/www/html/ as well as the files that currently reside in /var/www/html/.

I have a 4TB HDD mounted as /var. The space on this HDD is almost up, which is why I added another 4TB HDD that is not mounted yet. What I plan to do is create a mount point for this new HDD /mnt/a/ for example and then use mhddfs utility to merge /var and /mnt/a into a single mount point of /var with possibly following command:

mhddfs /var/,/mnt/a/ /var/

So that the two HDDs both have a single mount point of /var and no restart of the server to be necessary. Does mhddfs support executing such command when the resulting mount point is the same as one of the to-be-merged mount points? Or is there a better way of doing this?

8
  • You're unlikely to be able to mount a filesystem on top of another one and still use the underlying one. I'd suggest you test that carefully before going anywhere near your /var. Commented Jan 10, 2020 at 14:04
  • It is this one serverfault.com/questions/191299/… Commented Jan 10, 2020 at 14:07
  • Well, github.com/trapexit/mhddfs says categorically, "##PLEASE DON'T USE THIS## mhddfs is buggy, unsupported, and has some major security issues.". That's a pretty good reason not to use it. Commented Jan 10, 2020 at 14:09
  • Thank you, I was not aware mhddfs had such issues. They recommend mergerFS as an alternative that supports performing the same task, however my original concern of doing such merger still stands. Commented Jan 10, 2020 at 14:16
  • The only difference to the related question is that your existing HD is mounted as /var and you want to appear the merged file system at /var. Why not simply change the mount point of your existing HD to e.g. /var1 and mount the new HD as /var2 and merge these two as /var?
    – Bodo
    Commented Jan 10, 2020 at 14:38

1 Answer 1

1

As mentionned in comment, using mhddfs on a critical production system looks to be a bad idea.

The good way to solve your problem would be using LVM2. Below are the steps:

  1. Create a new LVM Volume Group (vgcreate) that used your new hard drive.
  2. Create a new LVM Logical Volume (lvcreate) from the previously created Volume Group.
  3. Format the Logical Volume using a filesystem that support resizing.

At this point, you have a clean, 4TiB filesystem. Then, i would:

  1. Mount the new filesystem to a temporary location (let's say /var-tmp).
  2. rsync /var /var-tmp.

At this point, you have a copy of your old /var on /var-tmp. Then:

  1. Stop every services relying on /var.
  2. umount /var.
  3. Mount your new, LVM based FS on /var instead.
  4. Restart services.

At this step, you have /var relocated to your new hard drive. Then:

  1. Use pvcreate to prepare your old HDD to be used on your LVM2 Volume Group.
  2. Use vgextend to add it to your Volume Group.
  3. Resize your FS.

Now you have a 8TiB /var.

NOTE: umount /var may be a bit complicated since several system daemon relies on it. If your system refuse to do so, you'll probably have to put it offline for a few minutes but, if well prepared, the unavailability of your system can be very short.

3
  • Thank you for the answer. I followed your suggestion exactly and did create a LVM logical volume, moved /var onto it, merged the old HDD using pvcreate and vgextend, and afterwards resized the FS to use 100% free space using lvextend and got this output from lsblk, where /dev/sdb was the old HDD and /dev/sdc is the new one (virtual HDDs, 4GB in size each). However, df shows that the lvm volume has 4GB available and I am unable to create a file bigger than 4GB in /var Commented Jan 10, 2020 at 20:54
  • I forgot that apart from resizing the LVM I had to also resize the filesystem using resize2fs for example. Afterwards df showed the correct size and all went well. You have my thanks, kind sir. Commented Jan 10, 2020 at 21:00
  • You're welcome :-)
    – binarym
    Commented Jan 11, 2020 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .