OpenVZ Forum


Home » General » Support » can VPSes share same folder ?
can VPSes share same folder ? [message #667] Thu, 05 January 2006 12:40 Go to next message
ntenev is currently offline  ntenev
Messages: 13
Registered: December 2005
Location: Bulgaria
Junior Member

Hi everyone,
is possible two (or more) VPS on same HOST to have access to same folder or files ? For example daemon from first VPS to writing something in a file and daemon from second to reading it ?

10x in advance
Re: can VPSes share same folder ? [message #720 is a reply to message #667] Sat, 07 January 2006 13:59 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

You can use bind mount for that, i.e. mount the same directory on the host system into two VPSs. For example:
mkdir /var/something
# Make sure VPSs are mounted
vzctl mount 101
vzctl mount 102
# Now mount the directory to both root areas
mkdir -p /vz/root/101/var/something
mount -o bind /var/something /vz/root/101/var/something
mkdir -p /vz/root/102/var/something
mount -o bind /var/something /vz/root/102/var/something


In order to make this change permanent, you can use mount/umount scripts, so 'vzctl mount' (and 'vzctl start' as well, as it involves mount) will do that bind-mounting, and 'vzctl umount' (and 'vzctl stop') will umount that directory.

For more info about mount/umount scripts, see "OpenVZ Action Scripts" section (which is on page 88 as of now) in OpenVZ User's Guide (PDF, 1.3Mb).

For example, mount script can look like this:
#!/bin/bash
# Mount script to bind-mount /var/something into a VPS
. /etc/sysconfig/vz
. $VE_CONFFILE

mount -o bind /var/something $VE_ROOT/var/something


And the umount script can look like this:
#!/bin/bash
. /etc/sysconfig/vz
. $VE_CONFFILE

umount $VE_ROOT/var/something


Hope this helps.


Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: can VPSes share same folder ? [message #791 is a reply to message #667] Wed, 11 January 2006 13:05 Go to previous message
ntenev is currently offline  ntenev
Messages: 13
Registered: December 2005
Location: Bulgaria
Junior Member

Yes, this helps exactly as I need ... very thanks !
Previous Topic: new kernel install
Next Topic: Install yum and lamp?
Goto Forum:
  


Current Time: Fri Apr 19 09:06:11 GMT 2024

Total time taken to generate the page: 0.01800 seconds