<?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>Shadow &#38; Honnix &#187; 虚拟机</title>
	<atom:link href="http://honnix.com/blog/archives/tag/%e8%99%9a%e6%8b%9f%e6%9c%ba/feed" rel="self" type="application/rss+xml" />
	<link>http://honnix.com/blog</link>
	<description>she&#039;s growing up</description>
	<lastBuildDate>Sun, 15 Jan 2012 10:44:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>对于虚拟机copy还是move的思路</title>
		<link>http://honnix.com/blog/archives/305</link>
		<comments>http://honnix.com/blog/archives/305#comments</comments>
		<pubDate>Sat, 11 Apr 2009 12:56:11 +0000</pubDate>
		<dc:creator>honnix</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MAC地址]]></category>
		<category><![CDATA[网卡]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://honnix.com/blog/?p=305</guid>
		<description><![CDATA[问题是这样的： 创了一个虚拟机，里面跑SuSE Linux，整个虚拟机拿给别人用的时候，会碰到copy还是move这样的疑问，目前看来，最大的区别在于网卡的MAC地址。如果是copy，MAC地址会重新生成，udev也会重新创建一个网络设备名，原来是eth0的话，现在就是eth1，这个还不是最关键的问题，关键在于SuSE Linux的网络配置文件名是和MAC地址绑定的，所以MAC地址变了，这个配置文件名也要相应地改变；如果是move，MAC地址保持不变，一切都没有问题，但是如果同一个虚拟机在一个主机上move两次，嘿嘿，MAC可就要冲突了。 简单来说，有两个解决方案： 每次都选择move，根本就不支持一个虚拟机在一个主机上move两次，也就是说，从我这里release出去的不同版本不能同时启动。 每次都选择copy，提供一个脚本修改网络配置文件名。 对于第二个解决方案，脚本的内容大致是这样： 1 2 3 4 5 6 7 #!/bin/sh &#160; suffix=`ifconfig &#124; grep 'HWaddr' &#124; awk '{print tolower($5)}' &#124; sed 's/:/\\:/g'` &#160; mv /etc/sysconfig/network/ifcfg-eth-id-* /etc/sysconfig/network/ifcfg-eth-id-$suffix &#160; /etc/init.d/network restart]]></description>
			<content:encoded><![CDATA[<p>问题是这样的：</p>
<blockquote><p>创了一个虚拟机，里面跑SuSE Linux，整个虚拟机拿给别人用的时候，会碰到copy还是move这样的疑问，目前看来，最大的区别在于网卡的MAC地址。如果是copy，MAC地址会重新生成，udev也会重新创建一个网络设备名，原来是eth0的话，现在就是eth1，这个还不是最关键的问题，关键在于SuSE Linux的网络配置文件名是和MAC地址绑定的，所以MAC地址变了，这个配置文件名也要相应地改变；如果是move，MAC地址保持不变，一切都没有问题，但是如果同一个虚拟机在一个主机上move两次，嘿嘿，MAC可就要冲突了。</p></blockquote>
<p>简单来说，有两个解决方案：</p>
<ol>
<li>每次都选择move，根本就不支持一个虚拟机在一个主机上move两次，也就是说，从我这里release出去的不同版本不能同时启动。</li>
<li>每次都选择copy，提供一个脚本修改网络配置文件名。</li>
</ol>
<p>对于第二个解决方案，脚本的内容大致是这样：</p>

<div class="wp_codebox"><table><tr id="p3052"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p305code2"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">suffix</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ifconfig</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'HWaddr'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print tolower($5)}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/:/\\:/g'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>ifcfg-eth-id-<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>ifcfg-eth-id-<span style="color: #007800;">$suffix</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>network restart</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://honnix.com/blog/archives/305/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

