Convert Vhdx To Vhd Hyper-v Manager

0 views
Skip to first unread message

Millicent

unread,
Aug 4, 2024, 12:57:15 PM8/4/24
to rabviwhistget
TheConvert-VHD cmdlet converts a virtual hard disk file by copying the data from a source virtual hard disk file to a new virtual hard disk file of a specified format and version type. The format is determined by the file name extension of the specified files, either .vhdx or .vhd. Conversion is an offline operation.

I need to convert a vmdk to vhdx to be used with Hyper-V. I converted the file using this:

qemu-img.exe -p -f vmdk -O vhdx -o subformat=dynamic C:\Hyper-V\Imports\VMWare\FreeRadiusAAMES\FreeRadiusAAMES.vmdk C:\Hyper-V\VHDs\FreeRadius.vhdx


Failed to Power on with Error 'The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.


I have a VM running on my server that I was hoping to move to Hyper-V on my desktop (Better performance, server is dual core). To do this I converted the vdisk to vhdx via the command qemu-img convert vdisk_copy.img -O vhdx -o subformat=dynamic win7.vhdx


Well, the VM (if a Windows VM) is expecting to boot off a virtual storage controller / disk using VirtIO drivers. What you need to actually do here will require some XML editing. First edit your VM's XML and for the for your OS, find the dev= and bus= part. Set dev=hda and bus=ide. Save and boot up Windows. When done, then shut down Windows and now go to convert your .img file the way you did. That should do the trick, but I honestly don't know because getting VMs off unRAID on to Hyper-V isn't something we support nor have experience with. Maybe some others here can give other advice, but what I suggested above should do the trick.


Hey John, I didn't actually move the VM over - just the vdisk. I created a new VM within Hyper-v and assigned the disk to it. I mean if it comes to it I can start from scratch but that is just time consuming. I'll keep playing around with it for now.


K, then my point still stands. Windows is booting up expecting the disk and controller to be using virtio which is not on hyper v. You need to first convert Windows to be ok with a generic storage device / controller on unRAID, then you can convert the image to vhdx format and run on hyper v.


The other option is to use the windows backup inside the unraid vm to create a system image, then boot from the windows DVD in hyper v and use the recovery tools to restore from the image into a fresh vhdx


I decided to start from scratch with a fresh windows 7 VM on a blank vhdx. Still no boot after install. The install completes successfully, reaches the 'Preparing your desktop' prompt and then instantly returns to 'Shutting down'. After that it's just a black screen with a blinking cursor. So rather than wasting time trying to get it working I just installed windows 8 instead using the same license key as my desktop. Not sure if this will cause problems or not, but I'm assuming it's okay..


It's also possible for Windows to lock a VHD file. I ran into this by double-clicking on a VHD, which causes recent version of Windows to open it up like a folder. However, it appears that the system then holds a lock on the file, which prevents Hyper-V from using it to start a VM. Rebooting fixed that problem.


While some of the simple answers provided above may work for some users, none of them solved my issue. My problem was that the Hyper-V .vhdx file for my virtual machine was locked but not appearing in either File Explorer as an ejectable disk nor in Administrative Tools Disk Management component. Note that my VM is a Debian Linux derivative running under WSL2 in Windows 10 with Hyper-V enabled.


So how did it become locked in the first place? I followed the instructions from an article on the web that said I can easily view files by simply double-clicking the .vhdx file. With the virtual machine shut down for the moment I did just that but got an error message (something about "can't read file"). Afterwards, trying to connect to my virtual machine with Hyper-V resulted in the error message "the process cannot access the file because it is being used by another process". So how to unlock it?


In my case, the culprit that was using the VHDX file was my backup software Backblaze (bztransmit64.exe), and this persisted even after a reboot (presumably it continued the backup from where it left off post reboot)


Oddly, Process Explorer did not return any hits when searching for the filename of the VHDX file, but I was able to identify the culprit by trying to rename the VHDX in Windows Explorer, nor did it return a handle for bztransmit64 itself


When you will click the virtual drive like computer\user\public\publicdocument\hyper-v\virtual machine\documents and settings the a new drive is opened in My computer. Right click the specified drive and "eject', then go to Hyper-V and start the Virtual Machine.


Go the your Hyper-V Manager, locate the failing Machine settings, go to its virtual Hard drive, inspect the drive on the right pane and then reconnect the drive.Finish the wizard and your machine will start normal.

3a8082e126
Reply all
Reply to author
Forward
0 new messages