网络上大部分都在说如何把VMware导入到VirtualBox中,我在最新的版本到看到VirtualBox (3.2.2)已经支持VMware虚拟硬盘格式vmdk,所以新建一个VBox虚拟机,直接注册VMware的虚拟硬盘就可以了。 / Q( \% _- z2 E3 x2 d# V' S; Q
其实没有必要把整个虚拟机相互转换,只要把虚拟硬盘镜像转换就可以了,不需要转换,但是要在VMplayer中使用VDI格式的硬盘镜像就得费点劲转换一 个格式了。
# {+ Q8 B, ]6 s2 j* A9 a# F9 d3 k使用第三种虚拟机来完成这个工作--qemu,
' Y$ ^$ Z+ Z1 z知道可以使用qemu-img来转换,按照上面的说明安装qemu-kvm,使用过程中发现可以当前的qemu版本已经支持几乎所有的虚拟硬盘格式,参照 下面的命令帮助。
( |6 w! s- |) h9 {在Ubuntu下可以很方便的安装 3 w# ]+ J! i+ b1 m# j4 w+ b3 y
shily@hh-desktop:~# sudo apt-get install qemu-kvm
) c2 Q x7 R! e( c使用如下一个命令就可以轻松完成转换。
/ s ?) n6 G% y8 Oshily@hh-desktop:~# qemu-img convert -f vdi -O vmdk Winxp.vdi Winxp.vmdk
# N8 t! e- |% y9 @. b4 R1 |) k直接修改已经建好的虚拟机,(Ubuntu系统在~/vmware/) 4 O9 ~1 }" T% y; _
例如我建立的虚拟机叫Win,则修改 ~/vmware/Win/Win.vmx,找到 ide0:0.fileName = "Win.vmdk" 0 P P5 [' m& j8 b! @
把其中的Win.vmdk修改成你转换生成的文件名即可。
3 O8 i, O) [/ l. z7 c; h[注]:
, g9 t3 m$ Q5 C3 d1 y" y, N1,Winxp.vdi要根据VitrualBox虚拟机的名称修改,在目录~/.VirtualBox/HardDisks下可以找到。 - z- t; Q, |; \7 p- \
2,.vmx 是VMware虚拟机的配置文件,是一个文本文件可以直接修改,也可以在程序中更改,删除原来的硬盘,再添加转换后的硬盘。 ' X/ i0 t: ~5 U6 }. N, T$ U; |8 ?: B
====================== , j- ]% l+ q6 K" q# p
shily@hh-desktop:~$ qemu-img
" S; `9 c1 T4 H, lqemu-img version 0.12.3, Copyright (c) 2004-2008 Fabrice Bellard . A! I$ l1 y8 [5 m) N) v0 ^0 G
usage: qemu-img command [command options]
5 p* F/ @. i1 {$ U3 B GQEMU disk image utility - h4 Y! M6 R6 n: y' {- c* S
& v) f }# P4 @2 NCommand syntax: , p) f: q, V! K1 z- q7 ^
check [-f fmt] filename & M9 Y; c# o9 h7 L3 S1 C
create [-f fmt] [-o options] filename [size]
/ M6 {$ X7 E5 s2 Hcommit [-f fmt] filename 8 I2 M4 w9 B3 Q! ~8 X
convert [-c] [-f fmt] [-O output_fmt] [-o options] filename [filename2 [...]] output_filename ' Y$ i {8 B0 u" j8 m
info [-f fmt] filename . A8 s- X# b) @% U- o. ]% x9 i
snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename
. J/ b: T- I6 I7 i/ A/ I
* o' G) ]/ g% z/ h9 ?" `Command parameters:
$ [' x. m& j% \; c: n- m'filename' is a disk image filename 0 y) ~, Q2 e5 }' R) W5 ]
'fmt' is the disk image format. It is guessed automatically in most cases
4 N" U! D4 E0 o$ j( Y9 Z' K7 x. e'size' is the disk image size in bytes. Optional suffixes
: _, i* q3 t1 w( k'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)
|3 V8 P/ o) f! U' wand T (terabyte, 1024G) are supported. 'b' is ignored. # W" L* u4 _2 O4 I& q$ I
'output_filename' is the destination disk image filename
4 M% _( g% k4 V) {'output_fmt' is the destination format
8 ~! ?( a6 A3 _& |, ?'options' is a comma separated list of format specific options in a
! L. s2 a" ^: U- }" Rname=value format. Use -o ? for an overview of the options supported by the ( R7 m5 [. z+ U+ R
used format 3 a) p0 E& p5 K+ v" x" T- R8 d
'-c' indicates that target image must be compressed (qcow format only)
4 D% _2 F+ Y- f. T7 W9 z'-h' with or without a command shows this help and lists the supported formats
; T2 N9 w7 V) }9 P5 {/ I
( ?" y2 e* X" A. SParameters to snapshot subcommand: 4 F$ i( U/ U% z/ i0 `& g) x
'snapshot' is the name of the snapshot to create, apply or delete
1 W3 ^* G5 X H$ p* {+ W j' p'-a' applies a snapshot (revert disk to saved state) 6 S* z! z7 Q" O q; W$ a: U
'-c' creates a snapshot
/ V, S. ] |, s9 p( d( a( m& D, C'-d' deletes a snapshot - s# }. k& Q+ E4 p
'-l' lists all snapshots in the given image
; v) M2 y" {. v5 v
2 l7 o% E% Z$ s4 |# S- \' o8 uSupported 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
* b( h9 a7 [ Y# q" ?! P0 l0 `1 h- ^; f
====================== ' F7 e0 @; U/ c% n
参考: 2 C% L y; _) j4 y. U/ N
======================================
$ R3 N" a$ i. M7 m) M2 M$ h( f: V2010-06-06 更新
/ U( a5 k4 v* j0 f! A警告:安装qemu-kvm可能导致virtualbox无法启动,在我的机器上出现了如下提示:
. s: }8 a/ m: e9 V, J* E
5 [$ r) R& z% zFailed 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:
7 f: ~4 E; `- K/ J" t: cResult Code:
0 G' ? X5 l! A) f: D; SNS_ERROR_FAILURE (0x80004005)
, y r& L) Q& ?$ ~Component:
9 j1 H9 R$ u6 B& Q4 ~) @Console ( x4 e* ] C; y. m* t# d
Interface:
; u$ {7 \& d1 M1 E6 u: XIConsole {6375231a-c17c-464b-92cb-ae9e128d71c3} : l, F3 Q) W j
2 m9 K; y2 w0 F$ Q) @: G说 可能导致的原因是我的系统环境比较复杂:安装在USB硬盘上,经常在T60p和Dell的740上工作,他们的 CPU一个是Intel、另外一个是AMD,比较郁闷。在网上找到一个解决方案。 % N3 X# X s4 F% z" U& [
shily@hh-desktop:~$ sudo modprobe -r kvm_intel #因为我当前的CPU是Intel,你也可以直接使用sudo modprobe -r kvm来删除kvm模块,无论你使用什么样的CPU。 , Y4 b1 Y' D1 z: X3 Z
然后打开VirtualBox就可以了,但是你需要在每次重启开机后执行这个命令,如果你需要启动Vbox的话。
r; @; F2 K- S5 y. l3 M/ R! r& _4 H2 {7 j
参照:
2 R9 y/ z0 w& [2 W+ \
% Z4 q- Z% B5 G: P1 y$ J* y很郁闷的是,我在开启虚拟机后发现USB设备已经可以在虚拟机中正常使用了,我并不清楚什么原因导致可以使用。 . @5 |) r( H+ _. C
========================== 9 y" {$ U' q$ B/ k) x
最新更新:9 D* u9 N. F; Y: v3 u
学习了些新东西,找到了原因。
7 ^/ r* _! ?, L' C发现我系统中的 /etc/udev/rules.d/10-vboxdrv.rules 文件不知道什么原因消失了。
4 F: D6 P2 s% ?3 M* ^4 z$ H3 @重新建立一个,写入以下内容:
! \! p. l9 t9 W; f! l5 N6 g
- d5 p! U9 K' n/ ]KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="root", MODE="0600"
$ B, `' y$ t' }/ ]2 z/ m: ESUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664"
, X3 M! z g5 }- i8 {0 b ISUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="vboxusers", MODE="0664"
- ?. q; u# _! r6 x/ U0 o; @3 `
0 v5 b+ b5 B3 L- A重新启动虚拟机,就可以使用USB了。 |