Mounting host directory inside container [message #52631] |
Thu, 17 November 2016 02:56 |
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
|
|
|
|
|