32

Is it possible to convert a VMWare vmdk image file to physical hardisk drive? I know VMWare 6.5 can use physical harddisk drive directly to get good performance, can I convert an existing vmdk file to physical harddisk drive go gain better performance?

3
  • 1
    There is very little performance difference between using vmdks and physical drives.
    – JamesRyan
    Dec 18, 2011 at 17:12
  • @JamesRyan it depends a lot on the configuration; if the VMDK is sitting in its own datastore, then yes, there is very little difference; but if the datastore contains other VMs, things are a lot different.
    – Massimo
    Feb 12, 2016 at 23:31
  • @Massimo well don't put it with other VMs then? There is still no need to convert it to a physical disk!
    – JamesRyan
    Feb 13, 2016 at 21:40

6 Answers 6

22

If you have qemu-img, you should be able to do all of this from a command line dealing just with image files.

qemu-img convert source.vmdk -O raw <path>
dd if=<path> of=/dev/<disk> bs=1G count=<target-gb-size>

That will write out whatever raw format the vmdk was out to a physical drive. Its better to use copy-on-write FS for this. Make sure that all source data allocated within first N Gb to fit the target disk of N-Gb size.

4
  • A tip: qemu version 1.2.0 fixes a bug that occurs when converting VMDK images. See serverfault.com/questions/429478/… Sep 18, 2012 at 13:49
  • @Alex I've windows system, So how to set "/target/drive/" ? Aug 24, 2016 at 11:26
  • I use qemu-img 1.4.0, I have to use qemu-img convert -O raw source.vmdk /target/drive/ to make it work
    – zw963
    Mar 25, 2017 at 20:36
  • May I know how do I launch my VM after performing this operation? There will definitely some VMX file editing involved, as it will still point the VM to the virtual disk it used to be on.
    – COOLak
    Nov 7, 2023 at 3:23
11

A bit late, but for reference I have successfully:

  1. Attach clonezilla to the virtual machine
  2. Boot the virtual machine with clonezilla disk
  3. Save an image of the disk to an external USB drive (also attached to the virtual machine)
  4. Restore the image to a physical disk using clonezilla
1
  • May I know how do I launch my VM after performing this operation? There will definitely some VMX file editing involved, as it will still point the VM to the virtual disk it used to be on.
    – COOLak
    Nov 7, 2023 at 3:24
3

You didn't mention what OS you're using and Alex's answer will not work on Windows and someone asked how to do this on Windows in the comments, so here's how:

You should use Cygwin to be able to use dd and accomplish the task.

Download and install Cygwin from here: http://www.cygwin.com/

Open Cygwin terminal as Administrator and type in:

cat /proc/partitions

You can see all your hard disks with their partitions. The numbers indicate the partitions.

dd if=/cygdrive/driveletter/path/to/vmdk bs=256k status=progress of=/dev/sdX
  • X in sdX is the drive that you want to write to. But remember it's different to Windows' drive letters. Don't mix them up!

  • status=progress will show you a progress line of dd.

  • bs=256k is block size (cache), you can use bs=4M for today hard disks but I am using 256k since I'm wring to a USB thumb drive.

Note: Beware that if the source machine is Windows 10, dd may not be compatible with converting the VMDK to RAW(disk), some similar situation reported here.


More info and commands on qemu-img here if you want to make sure it's not possible on Windows: https://cloudbase.it/qemu-img-windows/

7
  • May I know how do I launch my VM after performing this operation? There will definitely some VMX file editing involved, as it will still point the VM to the virtual disk it used to be on.
    – COOLak
    Nov 7, 2023 at 3:24
  • @COOLak Simply create a new Windows VM, or an existing one, no need to install an OS or have an ISO mounted btw. Just remove the VMDK that the new VM wizard creates and add your VMDK file you created, such as explained on this answer.
    – Shayan
    Nov 7, 2023 at 10:13
  • but the whole point is to get rid of VMDK and transfer the virtual machine to a physical SSD drive. So I don't understand what you mean by "and add your VMDK file you created". There isn't supposed to be one anymore.
    – COOLak
    Nov 7, 2023 at 11:11
  • @COOLak oh I see, I confused the question with Physical 2 Virtual (P2V). If you follow the dd command, all your partitions including the bootable partitions required to boot windows will be copied. Just open your BIOS settings, mark your SSD as the bootable disk if another disk is selected, and Windows most likely boots, but if it doesn't you will have to "repair" windows, in order for it to resolve the driver incompatibilities etc. And it will boot up. To get it into repair mode, there's a guide from Microsoft.
    – Shayan
    Nov 7, 2023 at 11:24
  • so basically it's mandatory to create a new VM, then just add the physical drive with my old VM to it and make it bootable? That's it? No need to edit VMX?
    – COOLak
    Nov 7, 2023 at 11:49
2

Have you tried booting into a BartPE cd (i.e. UltimateP2V ) and using Ghost? You'll probably run into driver problems once it gets on the hardware but, those are easy enough to deal with (in theory, lol).

If you want to create your own P2V (V2V, V2P, etc) disk check out Mike Laverick's write up (its the best): http://www.rtfm-ed.co.uk/docs/vmwdocs/whitepaper-ultimateP2V.pdf

1
  • May I know how do I launch my VM after performing this operation? There will definitely some VMX file editing involved, as it will still point the VM to the virtual disk it used to be on
    – COOLak
    Nov 7, 2023 at 4:29
2

Try UDPCast

The idea is to stream the whole your vmdk out of it's Virtual Machine to physical machine, where it is written to the physical hdd.

Procedure is outlined below.

Since you have a vmdk file, you might have a VMWare Workstation at your disposal, even complete Virtual Machine this vmdk is attached to. Run your Virtual Machine with this particular vmdk attached, but instead of ordinary boot use PartedMagic liveCD to boot from.

When liveCD is started, navigate to main menu and find the UDPCast Disk Cloning. Its dialogs are self-explanatory (see the screenshot) UDPCast Disk Cloning start screen

After selecting this Virtual Machine to be the sender, you should select which drive you want to broadcast (using Unix notation, like /dev/sda).

After you've started the sender, you need to start receiver as well. Since you have a physical hdd, I'm assuming, you also have a complete PC with this hdd attached to it. Same thing here: you need to start liveCD with UDPCast Disk Cloning selecting receiver this time as well as appropriate physical hdd.

Worth noting, that you should make all the necessary arrangements to have network connectivity between your Virtual Machine and physical hardware. You should take necessary precautions if your vmdk contains private data, since its contents would be effectively streaming over your network. Another thing is that your target hdd should have no less storage capacity, than your vmdk's capacity. It is obvious, but also worth noting that your image is laid out one-to-one on your target hdd and you need to perform suitable operations with gparted or the like to make use of greater capacity of your new hdd.

4
  • I'd like to note that this suggestion is straightforward and easy to achieve, since the only preparation needed is getting LiveCD with UDPCast (or any other LiveCD which is sufficient to download and run UDPCast) written to any bootable media. Let alone UDPCast is not so demanding in dependencies as qemu-img is. And there's more: UDPCast could be run directly from PXE. udpcast.linux.lu/bootloader.html#pxe
    – PF4Public
    Feb 17, 2016 at 13:15
  • May I know how do I launch my VM after performing this operation? There will definitely some VMX file editing involved, as it will still point the VM to the virtual disk it used to be on.
    – COOLak
    Nov 7, 2023 at 3:25
  • @COOLak Why would you want to run VM after converting its image to a real hard drive? You could attach that hard drive to your VM if you need.
    – PF4Public
    Nov 8, 2023 at 11:35
  • Because it's encrypted, and I use VM from an encrypted hard drive for additional security due to the nature of my work.
    – COOLak
    Nov 8, 2023 at 23:27
1

Mount the drive in a VM or however, and snapshot it (www.drivesnapshot.de). Then mount the raw disk in a VM and restore the snapshot onto the disk. That will transfer the drive sector by sector. In Linux I think you can use dd to do the same thing.

Isn't use of physical disks for VM volumes deprecated in VMWare these days?

JR

4
  • The feature still exists in Workstation and the runs-on-bare-hardware-ish products. You can't use physical partitions/disks in this way with VMWare Server or VMWare Player though. Jun 30, 2009 at 14:43
  • 2
    You can use physical disks fine in VMWare Server 1. I don't know about 2-- I can't stand it and won't use it. Jun 30, 2009 at 14:50
  • You can use any disk imaging software you prefer. I will often use a "helper VM" that has it's own boot drive and then mount the source and target drives. The VM has all the disk tools I usually use and makes it easy if you have to do this from time to time. Jun 30, 2009 at 14:54
  • May I know how do I launch my VM after performing this operation? There will definitely some VMX file editing involved, as it will still point the VM to the virtual disk it used to be on.
    – COOLak
    Nov 7, 2023 at 3:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .