Error when converting VmWare virtual disk to HyperV
Asked Answered
T

7

67

I received VmWare image from my client for some testing purposes. I need to convert it to Hyper-V. I followed steps in http://www.askme4tech.com/how-convert-vmware-virtual-machine-hyper-v. I installed Microsoft Virtual Machine Converter and started to convert virtual disks in PowerShell. However I'm getting eror:

C:\Windows\system32> ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "c:\temp\disk2.vmdk" -DestinationLiteralPath "c:\data\HyperV\PH\" -VhdType DynamicHardDisk -VhdFormat Vhdx

ConvertTo-MvmcVirtualHardDisk : The entry 1 is not a supported disk database entry for the descriptor.
At line:1 char:1
+ ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "c:\temp\disk2.vmdk"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Accel...nversionService:DriveConversionService) [ConvertTo-MvmcVirtualHardDisk], VmdkDescriptorParseException
    + FullyQualifiedErrorId : DiskConversion,Microsoft.Accelerators.Mvmc.Cmdlet.Commands.ConvertToMvmcVirtualHardDiskCommand

ConvertTo-MvmcVirtualHardDisk : One or more errors occurred.
At line:1 char:1
+ ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "c:\temp\disk2.vmdk"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Accel...nversionService:DriveConversionService) [ConvertTo-MvmcVirtualHardDisk], AggregateException
    + FullyQualifiedErrorId : DiskConversion,Microsoft.Accelerators.Mvmc.Cmdlet.Commands.ConvertToMvmcVirtualHardDiskCommand
Tholos answered 27/5, 2016 at 10:58 Comment(2)
please have a look at this sebmatthews.net/2014/06/…Plantation
@piyushjaiswal actually the steps described in the blog are the same as in the link I followed. But interestingly in the comments of the blog some people reported similar issue as I had. I answered them with link to my solution (but my comment is awaiting moderation, so I suppose the moderation notification ends up in spam and it will never be published :) )Tholos
T
91

I found some adhoc solution - a bit hack perhaps but it works at least.

Digging into similar issues found on google I came to a tool to extract disk descriptor out of the VMDK file. The content of the descriptor for my VMDK was something like this:

# Disk DescriptorFile
version=1
encoding="windows-1252"
CID=5379bf0f
parentCID=ffffffff
isNativeSnapshot="no"
createType="monolithicSparse"

# Extent description
RW 209715200 SPARSE "00054_C8PHS1096_151216-disk2.vmdk"

# The Disk Data Base 
#DDB

ddb.adapterType = "lsilogic"
ddb.geometry.biosCylinders = "13054"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosSectors = "63"
ddb.geometry.cylinders = "13054"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.longContentID = "64d4e008b7227bcce8aa54995379bf0f"
ddb.toolsInstallType = "1"
ddb.toolsVersion = "10241"
ddb.uuid = "60 00 C2 96 f7 70 f2 fd-b5 02 9e 46 6c df 00 2e"
ddb.virtualHWVersion = "10"

The error message together with the content of the extracted descriptor came to my attention, specifically the line:

ddb.toolsInstallType = "1"

as it contains the strange value of 1 from my error message. I edited the descriptor - just comment out that single line with # (hash mark), injected it back into VMDK and voila - the conversion works now.

Credits to this link https://communities.vmware.com/thread/343214?start=0&tstart=0 and of course to tools by Dariusz Stanislawek.

Just for reference, the steps I have done:

  • download and extract dsfok tools
  • use dsfo.exe "c:\temp\disk2.vmdk" 512 1024 descriptor1.txt to extract the descriptor
  • edit the descriptor file in Notepad++: comment the above mentioned line (as I added the extra single character (#) I also deleted one NULL character from the end to keep the file size of 1024 bytes (not sure if this is needed).
  • use dsfi.exe "c:\temp\disk2.vmdk" 512 1024 descriptor1.txt to inject the descriptor back into the VMDK
  • repeat these steps for the other disk (my VM has two .vmdk files)
  • reissue the ConvertTo-MvmcVirtualHardDisk command

REMARK

After creating VM in Hyper-V, the machine didn't boot, it remained in black screen with fast blinking cursor (so called black screen of death). I don't know if it was caused by the conversion or by the fact that original disks in VMWare had been SCSI while I attached them as IDE. To fix it, I attached DVD with image of Windows and booted from DVD. I ran the Rapair system, started the command line and ran

bootrec.exe /fixBoot

Finally, the VM boots and runs.. end of story.

Tholos answered 27/5, 2016 at 11:23 Comment(8)
perfect answer ! However for me the offending line was ddb.uuid.image="bb194edb-6cd9-416d-9241-bef35d41745f", so I removed all ddb.uuid.* entries. (It was a vmdk but formerly created with virtualbox and not vmware so that might have been the reason)Tamper
@Tamper I had to do the same. I was converting Oracle VMs to Hyper-V.Graphics
The ConvertTo-MvmcVirtualHardDisk command took a really long time, but it worked (using the method above). It took about 12 hours to convert a 150[GB] VMDK file. Even though it reached the 150[GB] size in about 1 hour, afterwards it kept writing at the same speed (multiple passes?) for 11 more hours.Spicule
This method actually only took 40 minutes. VBoxManage.exe clonehd --format VHD "My.vmdk" "My.vhd"Spicule
The dsof tool cannot be downloaded anymore from the link above. Does anyone have a backup of this tool?Dactylic
thaqnks, but I had a problem when I tried to convert a VMware VM with SAS HDD controller to Hyper-V. I could do it but the system do not work and even I can not see any boot drive in the Repare Tool of WIN 11 DVDISO Image. How can I bring my VMWare Win11 to Hyper-V work?Naucratis
@WalterSchrabmair Hi, sorry but this is 7y old post :-) and I was never a guru in virtualization. As you can see I just recorded my rather naive trial/error effort as it took me a day and it was not subject of my task at all.. If I were in your shoes I would try the tools dedicated to working with disk images mentioned by other answers here - qemu or starwind - they seem to be established tools..Tholos
@Tholos thanks you did a good job, I realized that I have to choose GENERATION 2 in the setup of VM with Hyper-V. Moreover in the meantime there is a good tool: https://www.starwindsoftware.com/tmplink/starwindconverter.exeNaucratis
T
21

I tried the above solution, but in my descriptor there wasn't toolsInstallType property so it didn't worked (with the same error).

After some research I found this tool: https://cloudbase.it/qemu-img-windows/

The command was like this:

qemu-img.exe convert c:\PATH_TO_FILE\disk.vmdk -O vhdx c:\PATH_TO_FILE\disk.vhdx -p

The documentation for this tool is here QEMU Documentation the -p flag allows you to see progress of the convert.

Also I found it easier to work with since it's a portable tool. In this specific case it does not require also to fix the bootloader, I just attached the vhdx to the new VM and it started successfully.

Thenar answered 2/12, 2016 at 14:23 Comment(5)
I know this is old, but just wanted to add that you can see the progress by looking at the growing file size in the output directory. If you know the input file size, the output will be about the same.Phospholipide
I used this tool to convert a vmdk to vhdx. The tool worked but the resulting vhdx is not bootable. Is there a trick to make it bootable?Antiseptic
In my experience, I ran into the same had to use New Virtual Machine Wizard to create my VM and specify Generation 1 instead of using Quick Create.Pertain
I just wanted to add that you can show progress on this tool using the '-p' argumentClyburn
After it converted 6.03GB (1% of total file for me), the size stopped increasing. I waited for half an hour but it looked like it got stuck. So I wanted to cancel this operation and run it again. When I pressed Ctrl+C the progress immediately jumped from 0 to 1 percent and continued working. I don't know what the heck was that. I just wanted to let the future readers know. So if it gets stuck, try that before completely canceling the operation. Make sure it is stuck by checking the filesize, not the progress in CLI.Cochineal
C
16

I had a this problem too trying to convert a VMWare image to VHD. My solution is similar to eXavier's, but I was able to do it with just a text editor.

The reason I could do a simpler fix was that the vmdk I got from VMWare was a small text file that referred to a number of other files. It looked like this:

# Disk DescriptorFile
version=1
encoding="windows-1252"
CID=4bd4d907
parentCID=ffffffff
isNativeSnapshot="no"
createType="twoGbMaxExtentSparse"

# Extent description
RW 8323072 SPARSE "Windows Server 2012-s001.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s002.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s003.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s004.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s005.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s006.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s007.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s008.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s009.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s010.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s011.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s012.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s013.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s014.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s015.vmdk"
RW 983040 SPARSE "Windows Server 2012-s016.vmdk"

# The Disk Data Base 
#DDB

ddb.adapterType = "lsilogic"
ddb.geometry.cylinders = "7832"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.longContentID = "439d288830654baf53d1f9594bd4d907"
ddb.toolsInstallType = "1"
ddb.toolsVersion = "10240"
ddb.uuid = "60 00 C2 97 21 a0 4e af-fc 21 68 15 2f 12 7f 22"
ddb.virtualHWVersion = "12"

The fix was to remove the #Disk Database line and all those below it, using a text editor, so that my file looked like this:

# Disk DescriptorFile
version=1
encoding="windows-1252"
CID=4bd4d907
parentCID=ffffffff
isNativeSnapshot="no"
createType="twoGbMaxExtentSparse"

# Extent description
RW 8323072 SPARSE "Windows Server 2012-s001.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s002.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s003.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s004.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s005.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s006.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s007.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s008.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s009.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s010.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s011.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s012.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s013.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s014.vmdk"
RW 8323072 SPARSE "Windows Server 2012-s015.vmdk"
RW 983040 SPARSE "Windows Server 2012-s016.vmdk"

It then converted to a VHD with no problems.

Cryptology answered 10/11, 2016 at 10:58 Comment(3)
This works. I had some trailing 0 on the last line (....vmdk"0) but I left it and it worked, no problem. Thanks.Foppish
So simple, so nice.Reiss
This worked perfectly for me. I opened the main vmdk file using Visual Studio Code, removed everything from # The Disk Data Base onward and then the conversion succeeded.Aalborg
I
13

I have another solution to this problem that worked for me so thought I would add it to the mix for any future readers.

I downloaded the StarWindConverter tool from here (its free).

https://www.starwindsoftware.com/tmplink/starwindconverter.exe

It supports multiple destination formats and gives you a nice wizard to walkthrough. Once you have selected all your options you get a progress screen like below:

progress-bar

The process of converting an offline .vmdk files to .vhdx was simple.

Irenics answered 11/4, 2018 at 6:52 Comment(4)
Soooooo easy, shut up an take my money! (but malware risk tho?)Hefty
I know right! - Its a fab free little tool and works like a charm. Also Starwind software seems like a reputable company so no malware. I have been using it for a while now and couldn't be happierIrenics
Worked perfectly for me, on Windows 10, converting a very very old Windows XP vmdk.Wilow
This was the best solution for me. Normally I am wary of these tools but you can't beat free. Way safer that digging into a production VMDK and risk any damage. The only complaint I have is that it is unable to do anything before the VM is shutdown. Would be nice if it could shutdown the VM like MS MVMC.Pya
I
4

Here is an answer using powershell/.net which doesn't require you to download anything extra. This worked for me. There is a little written about it here: https://badflyer.com/vmdx-to-vhd-conversion/

There may be something in the VMDK descriptor which the conversion cmdlet doesn't understand. In which case, just commenting it out should be good enough.

If you don't have notepad++ installed, you'll need to change which editor is opened.

Step 1:

# Open VM-ware disk, read 1024 bytes at position 512
$vmdkFileName = 'D:\VM\CNC Windows 7 Professional\Windows 7 Professional-cl1.vmdk'
$vmdkFileStream = [System.IO.File]::Open($vmdkFileName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite)
$vmdkFileStream.Position = 512

$bytes = [byte[]]::new(1024);
$vmdkFileStream.Read($bytes, 0, 1024)

# Write to a temp file
$tempPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetTempFileName())
$tempfile = [System.IO.File]::OpenWrite($tempPath)
$tempfile.Write($bytes, 0, 1024)
$tempfile.Dispose()

# Open the editor. Wait for exit doesn't always seem to work for npp...
# Use whichever edit you like, it needs to show text, and also helpful if it can show whitespace/control characters
$editor = Start-Process 'C:\Program Files\Notepad++\notepad++.exe' -ArgumentList $tempPath -PassThru -Wait
$editor.WaitForExit()

# TODO, change what is causing the problem in the opened file.

If the error message was complaining about a "1", then look for lines in the descriptor which have the value "1". For example: ddb.toolsInstallType = "1" You can comment it out like:

# ddb.toolsInstallType = "1"

Then save the editor and write the bytes back into the VMDK. Make sure when you save, you're using an editor which doesn't change the encoding of the data...

Step 2:

# Read back the temp file
$tempfile = [System.IO.File]::OpenRead($tempPath)
$tempfile.Read($bytes, 0, 1024);
$tempfile.Dispose()

# Write back to the vmdk
$vmdkFileStream.Position = 512
$vmdkFileStream.Write($bytes, 0, 1024)

# Cleanup
$vmdkFileStream.Dispose();
del $tempPath

Now try the conversion again.

Iglesias answered 21/1, 2020 at 15:16 Comment(2)
Worked for me! Not going to lie, I wish your Step1 and Step2 were combined. I was moving too fast and didn't even see Step2, it didn't work, then after closely looking at the code I couldn't figure how it was supposed to work...then Step2 closed everything out. I had a slightly different descriptor error, but I just # commented out a bunch of the descriptor and it worked. I preferred this solution because there's nothing to download and it gets directly to the actual issue as vanilla as possible.Silvanasilvano
Thanks for the native method. I wrapped it into a nice function, in case others want to use it.Zincograph
P
3

A complementary for answers above if you're still stuck with conversion.

In my case qemu-img.exe convert ... method succeed, but result .VHD image failed to start in Hyper-V:

Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.

Use a hex editor (edit block 0x100..0x200) or the dsfi.exe/dsfo.exe way described above to comment out these attributes in your .VMDK file:

ddb.uuid.image="... Some guid here ..."
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
ddb.comment=""

Just replace ddb -> #db.

After that, MMVC conversion succeed for me without failure, output image works:

Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"
ConvertTo-MVMCVirtualHardDisk -SourceLiteralPath .\win10-32-disk1.vmdk -DestinationLiteralPath . -VHDFormat Vhdx -VHDType DynamicHardDisk
Polluted answered 2/5, 2017 at 20:24 Comment(0)
C
1

Modern VMDK files have a main descriptor file and separate data files. There is no need to use dsfo/dsfi tools.

  • Ubuntu.vmdk <- the descriptor

  • Ubuntu-s001.vmdk, Ubuntu-s002.vmdk etc. <- data files

In this case You simply needed to comment out the line:

#ddb.toolsInstallType = "4"
Corum answered 5/12, 2020 at 18:56 Comment(1)
In my case it was just a single .vmdk file. After comment out the recommended line, the disk conversion worked as expected.Rotifer

© 2022 - 2024 — McMap. All rights reserved.