Bind mounts are awesome to mount stuff that is already mounted somewhere else. In my case, a customer added a additional hard drive to his server because he needed some extra space for one of the domains he was hosting on the server. Other than messing with RAID and trying to extend the file system we had a couple of options:
1. We could mount the whole drive as /path/to/his/domain
2. Mount the new drive as something like /mnt/newdrive and sym linking the domain to the new drive.
3. Mount the new drive as something like /mnt/newdrive and mount the domain directory as a bind mount.
I thought the third option was sexier since option number one could be a waste if the domain did not use all the available space on the drive and for option number two, some applications sometimes do not like the idea of following sym links, including open_basedir restrictions, etc.
Here is what I did:
On /etc/fstab mount new drive:
/dev/sdb1 /mnt/newdrive ext3 defaults 0 0
Move domain contents to new drive:
mv /var/www/vhosts/bigdomain.com /mnt/newdrive/bigdomain.com
On /etc/fstab add the bind mount:
/mnt/newdrive/bigdomain.com /var/www/vhosts/bigdomain.com bind defaults,bind 0 0
Now, for the new mounting points just run:
mount -a
Any suggestions are welcome.
–JC