VirtualBox拷贝vdi丢失eth0

今天用VirtualBox的工具去拷贝虚拟机vdi文件的时候,在拷贝出来的vdi文件中找不到eth0。

# debian lenny
VBoxManage clonevdi old.vdi new.vdi

拷贝成功,但当打开new.vdi的时候就出现eth0找不到了。原来是使用VBoxManage的时候不但会为新的vdi文件产出新的UUID,还会为其分配一个新的mac地址,以避免冲突,这样在debian中就会把新的mac地址设置为eth1,结果就杯具了。

解决方法有2个,其实差不多:

  • 在new.vdi中,修改/etc/udev/rules.d/70-persistent-net.rules,一般会有eth0和eth1两行,把eth0那行去掉,然后将eth1改成eth0。
  • /etc/udev/rules.d/70-persistent-net.rules中的内容直接删除,然后重启,让系统自动去检测网卡,然后重新生成该文件。其实在copy之前就可以删掉了,这样所有copy出来的都不用修改了,让系统自己去检测。

/etc/udev/rules.d/70-persistent-net.rules这个文件是在网卡有变动的时候才会变化的,里面记录着网卡的信息,虽然VBoxManage会为new.vdi创建新的网卡,但是debian的行为是把这个网卡作为新增的网卡记录在/etc/udev/rules.d/70-persistent-net.rules中,而没有进行调整,所以使用的还是有冲突的eth0。

This entry was posted in Unix/Linux. Bookmark the permalink.

2 Responses to VirtualBox拷贝vdi丢失eth0

  1. 玫子轩 says:

    博客风格我还是喜欢侧栏在左边, 你的….

  2. Stephen says:

    放在右边是因为我觉得右边拿着鼠标,如果想看侧栏的内容,右手会显示稍微顺手一点 :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>