博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Vmware虚拟机与VirtualBox虚拟机的硬盘镜像相互转换
阅读量:2299 次
发布时间:2019-05-09

本文共 4304 字,大约阅读时间需要 14 分钟。

Vmware虚拟机与VirtualBox虚拟机的硬盘镜像相互转换

关键字 Vmware VirtualBox  vdi vmdk 
公司不允许使用盗版软件,所以工作使用虚拟机是VirtualBox,但是在使用的过程中发现这个VirtualBox的USB搞不定,无法使用USB设备。没有办法只有转投Vmware,使用免费的VmwarePlayer。只是已经安装的VirtualBox虚拟机不想浪费了,毕竟已经安装了很多的软件。
网络上大部分都在说如何把VMware导入到VirtualBox中,我在最新的版本到看到VirtualBox (3.2.2)已经支持VMware虚拟硬盘格式vmdk,所以新建一个VBox虚拟机,直接注册VMware的虚拟硬盘就可以了。
其实没有必要把整个虚拟机相互转换,只要把虚拟硬盘镜像转换就可以了,不需要转换,但是要在VMplayer中使用VDI格式的硬盘镜像就得费点劲转换一个格式了。
使用第三种虚拟机来完成这个工作--qemu,
知道可以使用qemu-img来转换,按照上面的说明安装qemu-kvm,使用过程中发现可以当前的qemu版本已经支持几乎所有的虚拟硬盘格式,参照下面的命令帮助。
在Ubuntu下可以很方便的安装
shily@hh-desktop:~#
sudo apt-get install qemu-kvm
使用如下一个命令就可以轻松完成转换。
shily@hh-desktop:~#
qemu-img convert  -f vdi -O vmdk Winxp.vdi Winxp.vmdk
直接修改已经建好的虚拟机,(Ubuntu系统在~/vmware/)
例如我建立的虚拟机叫Win,则修改 ~/vmware/Win/Win.vmx,找到 ide0:0.fileName = "Win.vmdk"
把其中的Win.vmdk修改成你转换生成的文件名即可。
[注]:
1,Winxp.vdi要根据VitrualBox虚拟机的名称修改,在目录~/.VirtualBox/HardDisks下可以找到。
2,.vmx 是VMware虚拟机的配置文件,是一个文本文件可以直接修改,也可以在程序中更改,删除原来的硬盘,再添加转换后的硬盘。
======================
shily@hh-desktop:~$ qemu-img
qemu-img version 0.12.3, Copyright (c) 2004-2008 Fabrice Bellard
usage: qemu-img command [command options]
QEMU disk image utility
Command syntax:
check [-f fmt] filename
create [-f fmt] [-o options] filename [size]
commit [-f fmt] filename
convert [-c] [-f fmt] [-O output_fmt] [-o options] filename [filename2 [...]] output_filename
info [-f fmt] filename
snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename
Command parameters:
'filename' is a disk image filename
'fmt' is the disk image format. It is guessed automatically in most cases
'size' is the disk image size in bytes. Optional suffixes
'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)
and T (terabyte, 1024G) are supported. 'b' is ignored.
'output_filename' is the destination disk image filename
'output_fmt' is the destination format
'options' is a comma separated list of format specific options in a
name=value format. Use -o ? for an overview of the options supported by the
used format
'-c' indicates that target image must be compressed (qcow format only)
'-h' with or without a command shows this help and lists the supported formats
Parameters to snapshot subcommand:
'snapshot' is the name of the snapshot to create, apply or delete
'-a' applies a snapshot (revert disk to saved state)
'-c' creates a snapshot
'-d' deletes a snapshot
'-l' lists all snapshots in the given image
Supported formats: cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels nbd host_cdrom host_floppy host_device raw tftp ftps ftp https http
======================
参考:
======================================
2010-06-06 更新
警告:
安装qemu-kvm可能导致virtualbox无法启动,在我的机器上出现了如下提示:

Failed to open a session for the virtual machine WinXP.

VirtualBox can't operate in VMX root mode. Please disable the KVM kernel extension, recompile your kernel and reboot (VERR_VMX_IN_VMX_ROOT_MODE).

Details:
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
Console
Interface:
IConsole {6375231a-c17c-464b-92cb-ae9e128d71c3}
可能导致的原因是我的系统环境比较复杂:安装在USB硬盘上,经常在T60p和Dell的740上工作,他们的CPU一个是Intel、另外一个是AMD,比较郁闷。在网上找到一个解决方案。
shily@hh-desktop:~$
sudo modprobe -r kvm_intel          #因为我当前的CPU是Intel,你也可以直接使用sudo modprobe -r kvm来删除kvm模块,无论你使用什么样的CPU。
然后打开VirtualBox就可以了,但是你需要在每次重启开机后执行这个命令,如果你需要启动Vbox的话。
参照: 
很郁闷的是,我在开启虚拟机后发现USB设备已经可以在虚拟机中正常使用了,我并不清楚什么原因导致可以使用。
==========================
最新更新:
学习了些新东西,找到了原因。
发现我系统中的 /etc/udev/rules.d/10-vboxdrv.rules 文件不知道什么原因消失了。
重新建立一个,写入以下内容:
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="root", MODE="0600"
SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="vboxusers", MODE="0664"
重新启动虚拟机,就可以使用USB了。
回复麟麟麟:在某些情况下可能会造成无法使用,比如说UDEV权限问题。
2010-10-28 21:43
哥呀,因为usb,折腾的有点大阿。按照下面的步骤弄好:==============================先要安装闭源版的VirtualBox ,OES版的不支持USB。因为权限问题,普通用户是用不了USB的,所以还得设置下。1。增加用户组usbfs$ sudo groupadd usbfs2. 查看usbfs用户组的gid$ cat /etc/group | grep usbfsusbfs:x:1001:3.把当前用户增加到usbfs组$ sudo gedit /etc/group把usbfs:x:1001:修改为usbfs:x:1001:youname(改成你的用户名)4. 为USB设备重新设置权限编辑/etc/fstab文件,添加下面两行,注意你的gid可能不是1001$ sudo gedit /etc/fstab在末尾加上# 1001 is the USB group IDInone /proc/bus/usb usbfs devgid=1001,devmode=664 0 0重新启动后,应该就可以使用USB设备了 。==============================结果,还是不行,virtualbox中的usb是灰色的使用:$: VBOX_USB=USBFS VirtualBox &问题解决
2010-10-27 11:39
Vbox的闭源版可以分配USB
 

转载地址:http://yckib.baihongyu.com/

你可能感兴趣的文章
NSSet 集合
查看>>
集合之间相互转换
查看>>
集合的内存管理
查看>>
文件操作
查看>>
NSData
查看>>
日期操作
查看>>
iOS的三种弹框
查看>>
UIApplication和程序启动过程
查看>>
cocoaPods安装2017 以及遇到的坑
查看>>
Android中自定义可以选择中文的NumberPicker屏蔽弹出软键盘
查看>>
Scrapy教程——搭建环境、创建项目、爬取内容、保存文件(txt)
查看>>
SQL SERVER 2012 附加数据AdventureWorks2012失败解决方案
查看>>
C++内联函数(inline)的工作原理与例子
查看>>
Eclipse中使用svn主要命令的详细介绍
查看>>
MS第二题解题思路
查看>>
第一个mpi程序in linux
查看>>
epoll 详解
查看>>
Hadoop 面试题
查看>>
【Day22】mysql数据库的优化(一版)
查看>>
【Day23】几道值得研究注意的php相关问题(一)
查看>>