Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 ?
share|improve this question
I tried the option #3, but the lag it's too high – Magnetic_dud Mar 3 '11 at 23:50

2 Answers 2

up vote 7 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

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


share|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
Thanks! I corrected my answer. – Aleksandr Levchuk Mar 17 '11 at 20:59

the page give by Aleksandr Levchuk give the following script

echo '#!/bin/bash
. /etc/vz/vz.conf
if [ ! -e ${VE_ROOT}${DST} ]; then mkdir -p ${VE_ROOT}${DST}; fi
mount -n -t simfs ${SRC} ${VE_ROOT}${DST} -o ${SRC}
' > /etc/vz/conf/${CTID}.mount

chmod +x /etc/vz/conf/${CTID}.mount


so it's different from the mount --bind in his solution. I've tested the above script, and it works perfecly.

from what I've seen, "SIMFS is like a separate drive space set aside for virtual containers. It's set up for machine use, and prevents one containers virtual server from crashing any of the others."

So it should be better for security reason (plus the fact that it's in the official openvz documentation). However It could be interesting to assess the performance cost of this isolation.

share|improve this answer
Welcome to Server Fault. This is not a forum; answers are meant to only answer the question. If you have a new question you may ask it separately by clicking the Ask Question button. – Michael Hampton Jul 3 '14 at 14:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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