Difference between revisions of "Mounting base machine folders in container"

From Notes_Wiki
m
m
 
Line 1: Line 1:
<yambe:breadcrumb>OpenvZ|OpenvZ</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Virtualization tools]] > [[OpenvZ]] > [[Mounting base machine folders in container]]
=Mounting base machines folder 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.
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.
Line 28: Line 27:




<yambe:breadcrumb>OpenvZ|OpenvZ</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Virtualization tools]] > [[OpenvZ]] > [[Mounting base machine folders in container]]

Latest revision as of 13:11, 24 August 2022

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:

  1. 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.
  2. Give execute permissions to above file using:
    chmod +x /etc/vz/conf/<CTID>.mount
  3. 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