网络上大部分都在说如何把VMware导入到VirtualBox中,我在最新的版本到看到VirtualBox (3.2.2)已经支持VMware虚拟硬盘格式vmdk,所以新建一个VBox虚拟机,直接注册VMware的虚拟硬盘就可以了。 $ e7 T N& p, H% \& {( D
其实没有必要把整个虚拟机相互转换,只要把虚拟硬盘镜像转换就可以了,不需要转换,但是要在VMplayer中使用VDI格式的硬盘镜像就得费点劲转换一 个格式了。 ; g7 e9 c4 r$ X6 T% {8 Z5 ?
使用第三种虚拟机来完成这个工作--qemu,
$ Z- V" K# d# H知道可以使用qemu-img来转换,按照上面的说明安装qemu-kvm,使用过程中发现可以当前的qemu版本已经支持几乎所有的虚拟硬盘格式,参照 下面的命令帮助。 - ~, Z- q2 T! ]6 x$ ~2 O5 i) h
在Ubuntu下可以很方便的安装 $ U f, \' A4 |% }; P, D `
shily@hh-desktop:~# sudo apt-get install qemu-kvm
8 F( j, G3 v0 J/ n0 O使用如下一个命令就可以轻松完成转换。 3 O; m; O5 {) b6 O9 y7 O
shily@hh-desktop:~# qemu-img convert -f vdi -O vmdk Winxp.vdi Winxp.vmdk
# G4 c% ~; W+ J: u" t7 T直接修改已经建好的虚拟机,(Ubuntu系统在~/vmware/)
& y5 X) ]' g1 V6 U例如我建立的虚拟机叫Win,则修改 ~/vmware/Win/Win.vmx,找到 ide0:0.fileName = "Win.vmdk" : w2 ?6 i! P2 R1 O+ x* Q
把其中的Win.vmdk修改成你转换生成的文件名即可。
: _; d, P( H$ o/ c m2 f! M[注]:
8 z* W9 d4 N2 `, q+ I& c! e: |1,Winxp.vdi要根据VitrualBox虚拟机的名称修改,在目录~/.VirtualBox/HardDisks下可以找到。
6 q9 m) O. o+ f& {- \4 N( q2,.vmx 是VMware虚拟机的配置文件,是一个文本文件可以直接修改,也可以在程序中更改,删除原来的硬盘,再添加转换后的硬盘。
* h( U5 h" y- Q4 P====================== 5 @ @$ Q: |* `/ U# q
shily@hh-desktop:~$ qemu-img
3 r+ E. T& B, T: i+ zqemu-img version 0.12.3, Copyright (c) 2004-2008 Fabrice Bellard
' r# Z3 H* p+ r1 V$ Jusage: qemu-img command [command options]
) l" Q# Q4 Z* D- J6 m" }6 R# L- F+ vQEMU disk image utility
4 b7 ]8 S# i: |9 r9 G: m
+ d& x2 i) _ w) h$ |Command syntax: 7 ^$ ^- ~0 B8 s" e O: F
check [-f fmt] filename 4 c9 s5 n8 ]/ Q3 }; J3 D) h
create [-f fmt] [-o options] filename [size]
8 T( v& r ~' p/ `/ O# _) F) ?/ Fcommit [-f fmt] filename ) y* A0 a6 } F n w0 l
convert [-c] [-f fmt] [-O output_fmt] [-o options] filename [filename2 [...]] output_filename
- m7 S' e* H5 X) ~5 vinfo [-f fmt] filename 1 w6 c$ x' ]. w N) D( f
snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename 8 U0 \$ t& V: ~9 g v
) g0 ]9 b0 p/ c6 k0 E& J3 V
Command parameters:
# n2 }$ q# d& ~7 o' G'filename' is a disk image filename
) q6 D) u! }4 G* M d U/ T6 p3 {'fmt' is the disk image format. It is guessed automatically in most cases
$ a6 T7 W) V- C4 h'size' is the disk image size in bytes. Optional suffixes 1 d9 v" W8 v1 a4 q! ?2 y
'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M) ) q7 m6 Y1 O. d4 W2 u) S
and T (terabyte, 1024G) are supported. 'b' is ignored.
) ~& e2 @( {2 ~# R" W. l7 U2 f'output_filename' is the destination disk image filename
# R3 P$ W# [# ?'output_fmt' is the destination format
6 }# i4 p* l1 V7 G2 Q% z i'options' is a comma separated list of format specific options in a * S' B. ~# C5 q9 ^
name=value format. Use -o ? for an overview of the options supported by the 2 S2 U7 i$ q5 E2 u' E' ^% n9 E
used format
& U0 f4 I3 v2 t1 H L! x" W'-c' indicates that target image must be compressed (qcow format only) : _/ N& y2 @ i9 c
'-h' with or without a command shows this help and lists the supported formats
d8 e0 ~% _6 h+ p" E. L8 [* r6 H, Y. W8 M5 C/ P2 _
Parameters to snapshot subcommand:
4 e- R) u7 H5 _; s: h'snapshot' is the name of the snapshot to create, apply or delete
# t& l$ L# l: Y% b'-a' applies a snapshot (revert disk to saved state) - z4 |$ t1 w$ c1 S8 I. `7 P" c
'-c' creates a snapshot
9 h5 p8 u2 l. I' |& V'-d' deletes a snapshot ; z' \; x, P& s3 N _% `
'-l' lists all snapshots in the given image
& J5 C) s6 w$ g( w$ P! ~) Y: s4 l' e9 R5 K# o, L3 B
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 0 \ }% X r+ O' o# B ?$ r7 a
4 E' h5 m: J& S) S; {/ z5 U
====================== 8 A& I, L9 ^' m4 B
参考: ' Z# J& D5 o! _8 _
====================================== ) f5 G+ v1 y: {! [+ E H
2010-06-06 更新
- z9 x& X+ q" e3 o) h警告:安装qemu-kvm可能导致virtualbox无法启动,在我的机器上出现了如下提示: * c3 ~ c. X2 X9 m6 g
% R4 k! E$ t8 K8 O, i) i8 X( v
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:
( D3 D: Z3 M- F+ SResult Code: & i$ t2 X5 K! q0 l$ S* p
NS_ERROR_FAILURE (0x80004005) $ P7 D! {1 ? z$ t- q$ t
Component:
! h# d# U% t% J8 D9 TConsole & T7 x4 I8 B# i) a1 Z( s8 Y' U6 i
Interface:
! ? K( F* I ^9 s6 Z, M+ XIConsole {6375231a-c17c-464b-92cb-ae9e128d71c3}
+ S0 Z/ |% ] d9 f! ~9 A- t: n- f% G1 R9 e: \
说 可能导致的原因是我的系统环境比较复杂:安装在USB硬盘上,经常在T60p和Dell的740上工作,他们的 CPU一个是Intel、另外一个是AMD,比较郁闷。在网上找到一个解决方案。
# M2 D. d; X S% T: @shily@hh-desktop:~$ sudo modprobe -r kvm_intel #因为我当前的CPU是Intel,你也可以直接使用sudo modprobe -r kvm来删除kvm模块,无论你使用什么样的CPU。
$ C" [& R" }2 _7 X2 D" G9 p然后打开VirtualBox就可以了,但是你需要在每次重启开机后执行这个命令,如果你需要启动Vbox的话。 ; P$ u7 r5 p1 K5 Q' N5 E7 Z% @
; z8 @+ x# M7 P" W3 q4 [参照: - m' f" o. J5 C- J
K! K- ?: b$ z8 i0 a0 r很郁闷的是,我在开启虚拟机后发现USB设备已经可以在虚拟机中正常使用了,我并不清楚什么原因导致可以使用。
6 r* z5 O9 \2 {' [0 W========================== 1 `" q6 Y7 z/ O
最新更新:1 w b$ k4 t# B7 |
学习了些新东西,找到了原因。 / J5 U% l4 o; G. _
发现我系统中的 /etc/udev/rules.d/10-vboxdrv.rules 文件不知道什么原因消失了。 0 a9 V) a5 Y+ ^( s9 s9 m' M; F8 z
重新建立一个,写入以下内容: : ^2 r; Z9 Z @- i, {
8 O# k2 R; u: I7 c: [. t& f
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="root", MODE="0600" 7 n" o- i8 Q" }( L8 S
SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664"
h2 M3 J2 j) Z) U! M9 P6 RSUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="vboxusers", MODE="0664"
% r+ B1 i" a X$ D# k! m( S5 j
F/ W7 M' w4 N. M重新启动虚拟机,就可以使用USB了。 |