Due to better 64bit support, we decided to use VMWare instead of VirtualBox. To prevent of installing a gentoo to a VMWare image, I decided to convert the already working virtualbox image (a vdi file) to VMWare (vmdk).
Qemu-img is the command line tool for this task, using the following line, I can get a vmdk:
qemu-img convert -O vmdk gentoo32.vdi gentoo32.vmdk
However, this vmdk is not recognized by VMWare 6.5. I guess it has something to do with the fact that the original vdi file is using dynamic sizing (the file contains a 5G partition, and it only has 1.9G data, so the real size for the vdi file is about 2.1G): the converted vmdk is 1.9G, and VMWare reports that it has 2.1G total size.When booting with this image, VMWare fails to read any data from the virtual disk.
After tried another time with the above approach, which also failed, it seems I have to find another way.
Luckily, VirtualBox comes with a command line tool called vboxmanage, which can do all sorts of operations on vdi files, including converting vdi to raw disk image, so let’s try that:
vboxmanage internalcommands converttoraw gentoo32.vdi gentoo32.raw
The above command will generate a 5G gentoo32.raw file. Then use qemu-img:
qemu-img convert -O vmdk gentoo32.raw gentoo32.vmdk
To convert the raw file to vmdk. The resulting vmdk file is also 1.9G, but this time VMWare recognize it just fine (reporting its real size as 5G).
After changing the root device from
/dev/sda1 to
/dev/hda1, this image can boot just fine in VMWare, with one exception: the network interface eth0 can not be started. More inspecting reveals that “udev renames network interface eth0 to eth1″. This is caused by the fact that one of the default gentoo udev rule (
/etc/udev/rules.d/75-persistent-net-generator.rules) will write another rule file which saves the MAC address for each NIC, and sure enough, the MAC address for the NIC in VirtualBox is different from that of VMWare. However, this is very easy to fix, once you know where the generated udev rule is:
Open
/etc/udev/rules.d/70-persistent-net.rules and remove all rules in this file, save and reboot, eth0 won’t be renamed to eth1 any more.
January 18th, 2009 at 9:07 pm
Thanks for the hint. It really helps!
January 22nd, 2009 at 4:31 am
how to chang the root device from /dev/sda1 to /dev/hda1 ?
January 22nd, 2009 at 10:25 am
edit file /etc/fstab to change the root device
January 27th, 2009 at 6:32 am
where do I have to edit it? in the Vbox or in the Vmware
,because I can’t boot in vmware yet
I don’t have root device In Vbox /etc/fstab /dev/sda1 CEntos
———————————–
cat /etc/fstab
# This file is edited by fstab-sync – see ‘man fstab-sync’ for details
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/hdc /media/cdrom auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
February 13th, 2009 at 7:12 am
it’s working without editing file /etc/fstab ,just adding it like IDE0 existing harddrive to Vmware.
October 28th, 2009 at 10:05 pm
[...] (VMDK) is not as easy or straightforward as one would like. It turns out that you have to use the procedure shown here to first convert the disk to the fully-expanded raw format, and then convert it to the VMDK format [...]
November 16th, 2009 at 6:23 am
Thanks very much for the guide! I didn’t want to have to remake my windows vm.
February 11th, 2010 at 11:38 pm
Thanks for the guide, works like a charm!