PVS Reverse Image with VMware vCenter Converter

This post shows you how to perform reverse imaging of a vDisk to update either the PVS Target Device software, VMware Tools or something else that may break your PVS stream! We will be using a mixture of VMware vCenter Converter and Windows 2012 R2 to mount the VHD. This post will also (not something I was expecting it to) go over diagnosing the VHD (vDisk) if it becomes corrupt or the PVS image has a System Reserved partition.

To use Hyper-V on Windows 8+ to reverse image a vDisk see https://jgspiers.com/pvs-target-device-software-update-hyperv-reverse-image/.

Note that if upgrading PVS Target Device software v7.6.1, you don’t need to perform vDisk reverse imaging.

When using VMware vCenter Converter you need a machine to convert, so we need to mount the vDisk which is natively in the VHD format to a machine. Luckily with the likes of Windows 7/Windows Server 2008 R2+ you can mount VHDs with ease.

Below is my copy of Desktop.vhd which is a PVS vDisk. Hopefully your servers are running an operating system that can support mounting VHDs from Disk Management. This vDisk resides locally on my PVS server and from that server I will be mounting the VHD.

1-min

Navigate to Disk Management (Run -> diskmgmt.msc) click Action -> Attach VHD2-min

Click Browse and pick the VHD (vDisk) you want to mount.3-min

Click OK.4-min

Wait, the file or directory is corrupted and unreadable? OK, this could mean that the vDisk was created in 16MB blocks dynamically, but it wasn’t. The vDisk was created with a fixed size, however maybe PVS still creates it fixed with 16MB blocks. Anyway, VHDs with these block sized can’t be mounted, unless it is a 2MB block disk.5-min

Not to worry though, from the PVS server, launch CMD and navigate to C:\Program Files\Citrix\Provisioning Services\ or similar depending on where you installed PVS.

Now run command cvhdmount -p 1 “vDisk location”. The PVS vDisk is now mounted!6-min

You can confirm that by looking within Disk Management and seeing the new disk. Look at the System Reserved partition, some people have reported it giving errors in the past. It hasn’t really given me errors when used with PVS, and this particular vDisk has Windows Server 2008 R2 installed.7-min

Also in computer you can see the two vDisk partitions appear with drive letters.8-min

Launch your copy of VMware vCenter Converter and click Convert machine.9-min

Specify if the machine is powered on or off, and connection details of the PVS machine which currently has the vDisk mounted. Click Next.10-min

Specify if you want the VMware vCenter agent to automatically uninstall when the import succeeds or to do it manually yourself. Click Yes.11-min

Specify the VMware infrastructure server you want to place the converted machine on to and click Next. The next few screens ask for VM name, storage location etc.12-min

Specify the name you want to give the converted machine.13-min

Click on Edit to the right of the screen. We don’t want to copy all disks. We are only interested in F:\ and G:\ which are our vDisk partitions.14-min

Untick all non-vDisk partitions.15-min

Click Finish.16-min

At this stage the conversion begins.17-min

Moving along at 40%.18-min

Bang! Failed at 98%. An error occured during reconfiguration. Unable to update BCD on the destination machine’s system volume. Cannot find a system volume for reconfiguration. Something is wrong with the BCD configuration. If you just want to get rid of the System Reserved and move BCD to C:\ you can do that easily.

If it worked for you (in most cases it will) then you are good to go and can update the image as required then revert back to vDisk. If it didn’t work, you’re one of the unfortunate ones this time, like me, and will need to read on.19-min

Unmount the VHD from the PVS server by running command cvhdmount -u 1 “vDisk location”.

Boot your vDisk (in private image mode or maintenance mode) from a PVS Worker VM and then open Disk Management. Right-click the System Reserved partition and click Change Driver Letter and Paths.20-min

Assign a drive lettter such as E:\ to the System Reserved partition and click OK.21-min

We can confirm the partition now has drive letter E:\ assigned to it.22-min

Run CMD as administrator.23-min

Run command reg unload HKLM\BCD00000000.24-min

Run robocopy e:\ c:\ bootmgr to copy the bootmgr file from System Reserved to C:\.25-min

Run robocopy e:\boot c:\boot /s to copy the boot folder from System Reserved to C:\.26-min

Run the below BCDEDIT commands to set the bootmgr and memdiag device partition configurations. You can run bcdedit to confirm the device location for each entry is set to partition=C:.27-min

Navigate back to Disk Management and remove the E:\ letter from System Reserved, clicking OK on the warning message.28-min

Click Yes.29-min

Right-click C:\ and mark the partition as active.30-min

Click Yes.31-min

The C:\ drive is now marked as active.32-min

Restart the VM and then boot back in to the maintenance version or the private version.33-min

Once the VM is back online, navigate to Disk Management, right-click on System Reserved and click Delete Volume.34-min

Click Yes.35-min

The System Reserved partition is no more.36-min

Shutdown the VM. 38-min

Promote the maintenance version to production, click OK.39-min

Merge the maintenace vDisk to base (if you didn’t use the vDisk in private image mode).40-min

Mount the VHD back to the PVS server using command cvhdmount -p 1 “vDisk location”. You will now only see one partition, no System Reserved.41-min

Select the single partition to convert within VMware vCenter Converter.42-min

This time the conversion failed again, but the converted machine actually was created and visible within vSphere, with the VMDK (converted from VHD) attached. However when booting the VM, it couldn’t boot complaining with a bootloader error. How to fix?

Attach the Windows Server OS media to your VM, restart the VM and boot in to system recovery.

Once you reach system recovery, open CMD and type bcdedit.

As you can tell, thhe device locations are set to unknown which is clearly a problem. Not sure how it ended up like this but something was weird about the previous BCD configuration before conversion.

Run the following commands to reconfigure the locations:

bcdedit /set {bootmgr} device partition=C:

bcdedit /set {default} device partition=C:

bcdedit /set {default} osdevice partition=C:43-minNow the Windows Boot Manager and Boot Loader look configured correctly. Restart the VM. 44-min

And there you have it. Windows booting up.45-min

Finally! We can now upgrade PVS Target Device software and VMware Tools, then convert the disk back to vDisk.

 


15 Comments

  • Phil Waller

    July 30, 2016

    in all honesty, this is great, but you are better off simply using MDT 2013 and building a new image from that – and it works ..everytime, just swap out your PVS software for the latest version

    Regards

    Phil

    Reply
    • George Spiers

      July 30, 2016

      Rebuilding an image every time you want to upgrade VM tools or PVS Target Device Software? Some builds can take hours especially if not using layering i.e. AppDisk. Many images are highly tweaked and optimized to suit the user eperience and business case. You won’t find yourself often upgrading VMware Tools and since PVS Target Device Software 7.6 SP1 there is no need to reverse the image. Also whilst this post goes through diagnosing issues, 9.5/10 times a conversion will work fine and you can reverse image, update software and then run the imaging wizard to convert back to vDisk in no more than 1.5-2 hours.

      Reply
  • Josh

    August 14, 2016

    Thank you for all the time you put in to this….just upgraded to PVS 7.9 from 7.6, realized BNImage is no more, and spent the day trying to get Hyper-V, and BCDEdit methods to work unsuccessfully. Eliminating the System reserved partition allowed us to utilize P2PVS to reverse image successfully. Thank you!

    Reply
  • Kevin Estanislau

    August 15, 2016

    I went ahead and used the converter with success. Do you suggest uninstalling antivirus after you run the converter and then installing after you run the imaging wizard? We are using McAfee. Thanks for your help.

    Reply
    • George Spiers

      August 15, 2016

      Hi Kevin

      Some anti-virus products such as Sophos require a few file and services modifications to set a blank identity on the vDisk before streaming to production machines however this may not apply to McAfee. I would not uninstall unless the vendor suggests doing so or you have experienced trouble in the past.

      Reply
  • Jorge

    September 20, 2016

    Excellent guide! Very helpful – Thanks for putting it together. Just wanted to add that after getting the 98% error I re-tried disabling everything that sounded like reconfiguring the destination VM: “Reconfigure destination VM”, “Remove System Restore checkpoints on destination”, “Ignore page file” and “Create optimised partition” and this worked! Hope it helps others too…

    Reply
    • George Spiers

      September 20, 2016

      Thanks Jorge for the tips 🙂

      Reply
  • Pingback: PvS – Update vDisk – Carl Stalhood

  • Pingback: EUC Weekly Digest – July 30, 2016 – Carl Stalhood

  • Ray

    September 5, 2018

    Hey George
    How would I migrate pvs targets to a new vcenter infrastructure?

    Reply
  • Ray

    September 5, 2018

    Thanks man. I really appreciate your help

    Reply
  • Richard

    November 19, 2018

    HELP! I am getting BOOTMGR is missing after editing the boot files and rebooting as per your article. Have tried several times and gets to 98% with the same errors in VMware Converter.

    Reply
    • George Spiers

      November 20, 2018

      What is your reason for reversing the image? There are other methods available to reverse image if this method does not work for you.

      Reply
      • Richard Hughes-Chen

        November 21, 2018

        Hi George, thanks for coming back to me. The reason I was looking to reverse image was the requirement no longer needs a image based XenApp machine as it’s for Dev purposes only.

        I have had to abandon my attempts as tried XenConvert, P2PVS and VMware Convert all failing in some way.

        Would be good to know how this is resolved in case I need to or anyone else as the process seems to break the boot partition every time.

        Reply

Leave a Reply