OpenVZ Forum


Home » General » Support » Mounting host directory inside container
Mounting host directory inside container [message #52631] Thu, 17 November 2016 02:56 Go to next message
nebbian is currently offline  nebbian
Messages: 3
Registered: November 2016
Location: Western Australia
Junior Member
I'm looking for information on how to mount a directory that is visible to the host (/backup/openvz/vmbackup/) into a container (/backup/), so that the container can read/write to that directory.

I've previously deployed several OpenVZ 6 hosts, each with an OpenVZ container in it, and the way that always worked back then was to create a .mount file for the container, eg:

nano /etc/vz/conf/100.mount

#!/bin/bash
. /etc/vz/vz.conf
. ${VE_CONFFILE}
SRC=/backup/openvz/vmbackup
DST=/backup
if [ ! -e ${VE_ROOT}${DST} ]; then mkdir -p ${VE_ROOT}${DST}; fi
mount -o noatime -n -t simfs ${SRC} ${VE_ROOT}${DST} -o ${SRC}


Now in OpenVZ 7, I can't find a way to do this reliably. The documentation doesn't see fit to mention how to do this (at least that I could find, and I've looked at all the PDFs in the documentation).

The only way that sort of works (but doesn't persist across reboots) is to use the following:
mount --bind /backup/openvz/vmbackup/ /vz/root/c507428f-75d1-4ba6-b0ae-15424855b765/backup/

However this doesn't persist across reboots, so it's not a good solution. I've tried adding several variants of the following line to /etc/fstab on the host:
/backup/openvz/vmbackup/        /vz/root/c507428f-75d1-4ba6-b0ae-15424855b765/backup/   none    bind    0 0


however this doesn't seem to work when I do a mount -a, so won't work across reboots.


How are you supposed to mount a host directory inside a container?


Thanks for any ideas.

[Updated on: Thu, 17 November 2016 02:57]

Report message to a moderator

Re: Mounting host directory inside container [message #52632 is a reply to message #52631] Thu, 17 November 2016 03:47 Go to previous messageGo to next message
nebbian is currently offline  nebbian
Messages: 3
Registered: November 2016
Location: Western Australia
Junior Member
Hmmm it seems that the scripts are now located in:

/vz/private/{UUID}/scripts

You can create the following scripts:
mount
umount
start
stop


Note that start and stop run in the container context, while mount and umount run in the host context.

More info is here:
http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/li n/VzLinuxReference/367.htm
Re: Mounting host directory inside container [message #52636 is a reply to message #52631] Thu, 17 November 2016 16:23 Go to previous message
dim is currently offline  dim
Messages: 344
Registered: August 2005
Senior Member
You are right, you need to move your script to /vz/private/{UUID}/scripts/.

See also http://docs.virtuozzo.com/virtuozzo_7_command_line_reference /managing-containers/prlctlct.html#action-scripts


http://static.openvz.org/openvz_userbar_en.gif
Previous Topic: Windows Guest Network Adapter Ejection
Next Topic: vzkernel-debuginfo-2.6.32-042stab116.2
Goto Forum:
  


Current Time: Tue Mar 19 08:21:52 GMT 2024

Total time taken to generate the page: 0.02421 seconds