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

From Notes_Wiki
(Created page with "<yambe:breadcrumb>OpenvZ|OpenvZ</yambe:breadcrumb> =Mounting base machines folder in container= It may be useful to mount base machines folders in container. For example if ...")
 
m
Line 24: Line 24:


*Note: In case of yum cache remember to set '<tt>keepcache=1</tt>' 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
*Note: In case of yum cache remember to set '<tt>keepcache=1</tt>' 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
<yambe:breadcrumb>OpenvZ|OpenvZ</yambe:breadcrumb>

Revision as of 03:42, 4 January 2014

<yambe:breadcrumb>OpenvZ|OpenvZ</yambe:breadcrumb>

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.

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



<yambe:breadcrumb>OpenvZ|OpenvZ</yambe:breadcrumb>