Resetting a bootable VHD for another hardware architecture

Today I tried putting a laptop bootable VHD image onto a different laptop. I had tried this before and it wouldn’t boot. There are two problems actually:

  • The VHD file when expanded to its full size (126 GB) which happens at boot time, was then too big to fit on the available space of the HDD. Microsoft has a new Blue Screen of Death number (0x135 I think) that comes up when this happens.
  • The VHD had to be serviced with driver files for the different laptop so it would actually be able to boot up Windows on this laptop.

To solve the resize problem is quite involved. The VHD has to be attached to a virtual machine, defragged and then shrunk in that VM. In this case defrag didn’t itself achieve anything beyond what shrink itself could do, but the latter did bring the size down to 72 GB which should be acceptable.

This page here gives one methodology with the steps you can use. I simplified this somewhat and just shrunk the partition in Disk Management of Computer Management. I then moved the VHD back to the server it was originally on and then ran a tool mentioned on that page called VHDResizer to size the VHD to the partition size. This basically works by creating a new VHD file and copying the existing one to it. The web page as mentioned above probably allows much greater levels of resize but it already took so long to get the VHD defragged and so on that I cut out some of the steps in the web page and just lived with the VHD being larger than desirable.

The next step is DISM using in this case the Chipset drivers for this laptop which are the ones that contain disk drivers, finally the disk got copied to the laptop and rebooted, which worked. Finally!