Introduction

Bind mounts can be used to make directories on the hardware node (Proxmox node) visible to the container.

To mount the host system's /mnt/disk directory available to a container 777 (remember change “777” for the correct CT's ID):

1- Create a file named 777.mount inside /etc/vz/conf:

# nano /etc/vz/conf/777.mount

2- Insert the following:

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

NOTE: with “SRC” and “DST” variable you can control source directory and destination directory respectively.

If you want read-only mount, add -r option to mount command.

3- Assign execution permission to the above file:

# chmod +x /etc/vz/conf/777.mount

When you restart Proxmox or CT you can see mounted /mnt/disk inside the 777 CT.

References

https://openvz.org/Bind_mounts