1

I have SSD and HDD hard drives on server.

SSD mounted to /

HDD mounted to /mnt/

I have 20 (planning more) sites with 5-20 GB content each.

I want to store

/home/user/domain1.com/ to SSD

/home/user/domain1.com/wp-content/uploads/ to HDD

And same for other domains

/home/user/domainN.com/ > SSD /home/user/domainN.com/wp-content/uploads/ > HDD

How to do it ?

I founded How do I mount sub-directory to a hard drive in Linux? , but its only for 1 drive/dir. Is there way to make some symlinks or something like this, which points to direct dir on other hard drive?

For example,

/home/user/domain1.com/wp-content/uploads/ points to /mnt/domain1.com/ /home/user/domain20.com/wp-content/uploads/ points to /mnt/domain20.com/

Thanks in advance!

1 Answers1

1

You doesn't need any "mounting" at all, you can simply symbolic-link the folder like that:

for domain in domain1.com domain20.com; do
  mkdir /mnt/$domain
  mv /home/user/$domain/wp-content/uploads/* /mnt/$domain
  rmdir /home/user/$domain/wp-content/uploads/ 
  ln -Ts /mnt/$domain /home/user/$domain/wp-content/uploads/ 
done

PS: it is possible to use bind mount also, but it's bit more cumbersome to setup automatically at boot, something like this should work:

for domain in domain1.com domain20.com; do
  mkdir /mnt/$domain
  mv /home/user/$domain/wp-content/uploads/* /mnt/$domain
  mount --bind /mnt/$domain /home/user/$domain/wp-content/uploads/
  echo "/mnt/$domain /home/user/$domain/wp-content/uploads/ none bind 0 0" >> /etc/fstab
done
silmaril
  • 521