I want to share a directory from an OpenVZ container to another container, how I could do that?

  1. do a symlink from /vz/private/109/common-stuff to /vz/private/108/common-stuff ?
  2. bind mount /vz/private/109/common-stuff to /vz/root/108/common-stuff ?
  3. Share the directory with samba from the container, mount on the host, then bind mount to /vz/root/108/common-stuff ?
link|improve this question

I tried the option #3, but the lag it's too high – Magnetic_dud Mar 3 '11 at 23:50
feedback

1 Answer

up vote 3 down vote accepted

OpenVZ is great at letting you share directories without the need for Samba or NFS overhead.

To see how it works do a bind mount to root (not private) when the container is running:

mount --bind /vz/private/109/common-stuff /vz/root/108/common-stuff

To make the share persistent over container reboots:

  1. Put Script A into /etc/vz/conf/108.mount
  2. Run chmod +x /etc/vz/conf/108.mount

Script A

#!/bin/bash
source /etc/vz/vz.conf
source ${VE_CONFFILE}
mount -n --bind /vz/private/109/common-stuff /vz/root/108/common-stuff

Reference: http://wiki.openvz.org/Bind_mounts

link|improve this answer
I wanted to try this, but since I am not a linux guru, I was scared for data corruption. Thanks – Magnetic_dud Mar 2 '11 at 18:29
on the container reboot I don't get the automount? strange – Magnetic_dud Mar 4 '11 at 0:24
got it, the 108.mount should give a reference to 108.conf – Magnetic_dud Mar 4 '11 at 0:35
1  
Thanks! I corrected my answer. – Aleksandr Levchuk Mar 17 '11 at 20:59
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.