Mounting base machine folders in container
From Notes_Wiki
Home > CentOS > CentOS 6.x > Virtualization tools > OpenvZ > Mounting base machine folders in container
It may be useful to mount base machines folders in container. For example if base machine has same OS as the container then the package cache (yum or apt) can be shared between base machine and container so that same packages are not downloaded again. The same can also be used for making two containers share a folder.
To use yum-cache from base machine or any other folder for that matter on container use following steps:
- Create file '/etc/vz/conf/<CTID>.mount with following contents:
- #!/bin/bash
- . /etc/vz/vz.conf
- . ${VE_CONFFILE}
- SRC=/var/cache/yum
- DST=/var/cache/yum
- if [ ! -e ${VE_ROOT}${DST} ]; then mkdir -p ${VE_ROOT}${DST}; fi
- mount -n -t simfs ${SRC} ${VE_ROOT}${DST} -o ${SRC}
-
- and replace SRC, DST values as felt appropriate.
- Give execute permissions to above file using:
- chmod +x /etc/vz/conf/<CTID>.mount
- Now restart container and you should see the desired folder mounted. Note that quotas will not apply and entire space available on partition where given folder is located will be available to container.
- Note: In case of yum cache remember to set 'keepcache=1' in base machine and all containers so that packages do not get deleted after installation. You can consider modifying the template so that new containers automatically have keepcache=1
Home > CentOS > CentOS 6.x > Virtualization tools > OpenvZ > Mounting base machine folders in container