Combine several mount folder in multiply server into one folder

Nam Ha Bach's photo
Nam Ha Bach
·Sep 6, 2022·

1 min read


I have 04 servers:

  • 01 Master server: s1
  • 03 Client: s4 s5 s6

I need one "master" folder combine folder in three client


  1. In master server Create ssh public key with ssh-keygen command.
  2. In client Save public key to .ssh/authorized_keys to login without password Create share folder mkdir /root/s6 Note: sx is hostname
  3. In master server Create mount point: mkdir /root/share/s6 mkdir /root/share/s5 mkdir /root/share/s4 Create combine point: mkdir /root/share/all Install sshfs and mhddfs: apt-get install sshfs mhddfs Mount remote folder: sshfs root@x.x.x.x:/root/s4 /root/share/s4 sshfs root@x.x.x.x:/root/s5 /root/share/s5 sshfs root@x.x.x.x:/root/s6 /root/share/s6 Combine all: mhddfs /root/share/s4,/root/share/s5,/root/share/s6 /root/share/all -o allow_other


Run df -h

root@x.x.x.x:/root/s6                  20G  9.9G  8.5G  54% /root/share/s6
root@x.x.x.x:/root/s4                    20G  9.8G  8.6G  54% /root/share/s4
root@x.x.x.x:/root/s5                    20G  9.7G  8.7G  53% /root/share/s5
/root/share/s4;/root/share/s5;/root/share/s6   58G   30G   26G  54% /root/share/all

Touch /root/share/test.txt. test.txt will be created in most free space mount point automatically.

Share this