Christian HagerSoftware Engineer // Technical Director // Photographer

Creating and recovering Windows 8.1 installations via vhdx-image

Today I figured out how to recover a computer from a vhdx-image I created (using disk2vhd) earlier after doing a fresh install on this computer. The computer I recovered was one of our lenovo notebooks which had a broken harddisk. To fix and upgrade it we ordered a new Samsung SSD which I put in an external usb-case to do the recovery from my vhdx-image.

After doing that the following steps had to be completed to get the computer up and running again:

Step 1 – mount the vhdx-image using diskpart

Run cmd.exe and execute the following commands to mount backup.vhdx.

diskpart

> select vdisk file F:\backup.vhdx
> attach vdisk
> exit

Step 2 – Create a wim-image from the virtual drive you mounted in step 1

To do this I used a small utility from microsoft called imagex. Unfortunately to get this small 736KB tool I had to download the much larger Windows ADK which includes it under C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\DISM. If any knows where to download imagex seperately feel free to add the link in the comments. Once installed and added to our path we can use it to create the wim-image.

imagex /capture D:\ F:\backup.wim “boot drive”

In my case the vhdx-image has been mounted to d: (change that to whatever drive-letter the image has been mounted on your system) and I write my wim-image back to drive f: next to my vhdx-image.

Step 3 – eject the VHDX

Once the wim-image is ready we can eject the virtual drive using diskpart again

diskpart
> select disk 0
> select vdisk file F:boot.vhd
> detach vdisk
> exit

Step 4 – apply the wim-image to our new physical disk (the new ssd)

Now we use imagex to apply our wim-image from f:\backup.wim to our new ssd with the drive-letter E:\. The 1 in front of our target-drive selects the 1st image in the wim-file. Since we just created the wim-file it contains only one image.

imagex /apply F\:backup.wim 1 E:\

Step 5 – Install the new SSD into our notebook

At this point we should have finished writing the image to the physical drive so we can install the drive into the computer.

Step 6 – Check if the computer boots and eventually fix the boot configuration

If the computer boots correctly we done at this point. If not we have to boot from a recovery-cd or usb-stick and fix the boot configuration. I used a recovery-usb-drive (this article describes how to create one).

Once the recovery-installation has booted up we open up the console and execute the following commands.

bootrec /fixmbr
bootrec /fixboot
bootrec /scanos
bootrec /rebuildbcd

If all went well we should now be able to reboot the computer and are good to go.

All in all recovering the computer from the image saved me a lot of time compared to doing a complete reinstallation including updates and so on.

Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *