<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>NewPush &#187; Bind Mount</title> <atom:link href="http://newpush.com/tag/bind-mount/feed/" rel="self" type="application/rss+xml" /><link>http://newpush.com</link> <description>Server Hosting, Data Warehouse Hosting, Collaboration</description> <lastBuildDate>Fri, 20 Apr 2012 10:25:44 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>OpenVZ shared directory mounting from host to guest systems</title><link>http://newpush.com/2010/02/openvz-shared-directory-mounting-from-host-to-guest-systems/</link> <comments>http://newpush.com/2010/02/openvz-shared-directory-mounting-from-host-to-guest-systems/#comments</comments> <pubDate>Wed, 10 Feb 2010 09:19:05 +0000</pubDate> <dc:creator>Balazs</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Bind Mount]]></category> <category><![CDATA[OpenVZ]]></category> <category><![CDATA[Virtuozzo]]></category> <category><![CDATA[vzctl]]></category><guid isPermaLink="false">http://www.wdream.com/?p=515</guid> <description><![CDATA[Problem An OpenVZ host can share any part of its filesystem with any guest operating system running on it. This post describes how to manually mount a filesystem tree from the host OpenVZ box to a guest, and how to &#8230; <a href="http://newpush.com/2010/02/openvz-shared-directory-mounting-from-host-to-guest-systems/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<h4>Problem</h4><p>An OpenVZ host can share any part of its filesystem with any guest operating system running on it.  This post describes how to manually mount a filesystem tree from the host OpenVZ box to a guest, and how to automate the process.  We will also address an error that can happen with a correctly configured file preventing the automated mount process.</p><h4>Solution</h4><h5>Manual mount</h5><p>To mount a filesystem tree to any guest from the host, run the following:<code><br /> mount --bind /path/to/tree/on/host ${VE_ROOT}/path/to/tree/on/guest</code><br /> You need to replace <code>${VE_ROOT}</code> with <code>/var/lib/vz/root/&lt;guest id></code></p><h5>Automate the mount</h5><p>There is two options to automate the mount: automation for each guest and automation for a specific guest.  The file looks the same either way.  For setting up a mount on each guest, use <code>vps.mount</code> and <code>vps.umount</code> as the file names.  To use automated mount for a specific guest, use the the filename that is <code>&lt;guest id>.mount</code> and <code>&lt;guest id>.umount</code>.  For example, if your container id for your virtual private server (guest) is 123, then the specific files to set the mount and unmount code for are <code>123.mount</code> and <code>123.umount</code>.  This is how the <code>.mount</code> file needs to look:<code></p><p>#!/bin/bash<br /> source /etc/vz/vz.conf<br /> source ${VE_CONFFILE}<br /> echo "Starting ${VEID}.mount..."<br /> mount --bind /path/to/tree/on/host ${VE_ROOT}/path/to/tree/on/guest<br /> echo "...${VEID}.mount complete"<br /> </code><br /> And this is how the <code>.umount</code> file needs to look:<code></p><p>#!/bin/bash<br /> source /etc/vz/vz.conf<br /> source ${VE_CONFFILE}<br /> echo "Starting ${VEID}.umount..."<br /> umount ${VE_ROOT}/path/to/tree/on/guest<br /> echo "...${VEID}.umount done"<br /> </code><br /> Note that the <code>echo</code> is necessairy, otherwise, the filesystem will most likely not mount correctly.  This is due to the fact that on <code>start</code> and <code>restart</code> the <code>vzctl</code> program will call <code>umount</code> first, and if that script fails (returns a non zero exit code) the <code>.mount</code> script isn&#8217;t called.  Thus, if the directory isn&#8217;t mounted and there isn&#8217;t an <code>echo</code> at the end of the script, the script returns the exit code of the last command which in this case is the exit code from the failed <code>umount</code> command.</p><h4>References</h4><ul><li><a href="http://forum.openvz.org/index.php?t=msg&#038;goto=38348&#038;">OpenVZ Forum</a></li><li><a href="http://wiki.openvz.org/Bind_mounts">OpenVZ Bind Mounts</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://newpush.com/2010/02/openvz-shared-directory-mounting-from-host-to-guest-systems/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Served from: newpush.com @ 2012-05-22 10:58:49 by W3 Total Cache -->
