BizTalk & Development Thoughts

This is a blog about my experience with development specially for BizTalk ...

Booting from a VHD GOTCHAS

Booting from a VHD GOTCHAS

Rate This
  • Comments 4

So I wanted to convert my virtual machine into a native boot, how hard can that be? Well because I am so lucky (maybe not!) I faced and done all the wrong steps and took all the bad turns. In this post I will concentrate more on the bad things I made and the problems I faced maybe to help you avoiding them.

So I started off by reading how to do this over the internet and I found several very good blogs on how to perform this task and I will not go through all the the steps in detail as you will find them more detailed over so many places. Now what was different is that all blogs were talking about building your VHD and installing the OS from scratch. But in my case I already had my VHD ready and it is working in Hyper-V and I have installed all software I need but I had a memory problem (see I am running on a 4GB laptop :( ). So I prepared myself and came up to a checklist of steps to make as follows.

  1. Edit the boot entry in my machine and add a new one pointing to my already existing VHD.
  2. Start my VHD in Hyper-V as usual and SYSPREP it to remove all drivers' dependencies.
  3. Restart my machine and then choose the new VHD boot and start it in safe mode.
  4. Allow it to install device drivers and restart. AND viola all done

Let me walk you through my experience. So I started by adding the new boot using BCDEDIT command lines

bcdedit /copy {default} /d "MY vhd boot"

bcdedit /set {guid} device vhd=[F:]\My.vhd

bcdedit /set {guid} osdevice vhd=[F:]\My.vhd

Then I said I am not going to perform sysprep! So restarted my machine and BAM it is saying that there is a bad entry in the boot store and press enter to continue that led me back to my original OS. So I checked and found that my BIOS had disabled by default bringing up and booting from USB drives and since my VHD is on an external USB drive it failed.

So I enabled this option and it tries to load and BAM blue screen of death. So I am thinking my mistake as I did not perform SYSPREP right. So I performed SYSPREP and restarted my machine (you will be hearing this many times as we go on) and BAM again the same BSOD with the same error code. I tried to start in safe mode and it got stuck on loading disk.sys device driver!!!! I binged the internet and after so many reties (that took two full days of my life) I figured it out.

 

GOTCHA #1:

If VHD booting is stuck at DISK.SYS while booting in safe mode then remember that you CANNOT boot a VHD from an external HDD.

 

So I moved my VHD to my internal HDD and had to delete and move lots of stuff to do this. I changed my boot store information, restarted my machine and BAM still BSOD. But wait this is a different error this time it is saying that it was not able to expand the VHD. I returned to the good old internet and found that during the booting process from a VHD if this VHD is dynamically expanding; it needs to be expanded to the maximum capacity while booting up. You are kidding me right! Now I had created this VHD as a dynamically expanding VHD with a maximum size of 127GB! Now my physical HDD has a total space of like 80GB so even if I formatted my machine I would not be able to boot up this machine. So I binged the internet again and this time for a way to reduce the maximum size of my dynamically expanding VHD. And to my surprise I found nothing, NILL, NULL. (I even found a guy talking about a way to do this using Linux OS, right so I have to install Linux to get this VHD booting up). Then I thought about a solution; how about using the windows backup and recovery process. So here is what I done.

  1. Started by attaching the VHD to my already running OS using storage manager.
  2. Opened Windows backup and created an on-demand backup of all the volumes on this VHD (two BTW one as system reserved and the one that is my OS C volume)
  3. Then I created a new VHD with a fixed size of 40GB and attached that using the storage manager.
  4. I created two volumes on this new VHD one with 100MB as system reserved and one with the rest.
  5. I used the Windows backup to perform a recovery of the backed up volumes to the new created volumes.
  6. Then I tried to boot the new VHD in Hyper-V and it did not work. I inserted the Windows setup disk and started repair console. I checked the boot store using BCDEDIT and it was wrong so I had to rebuild that.
  7. First I noticed that it assigned a letter C to the system reserved volume and that the C volume is now assigned letter D.
  8. I used DISKPART to fix this by using the commands below

DISKPART
LIST VOL
SELECT VOLUME 1

REMOVE LETTER=C

SELECT VOLUME 2

ASSIGN LETTER=C

EXIT

  1. Then I fixed the boot manager record in the record store as follows

BCDEDIT /set {bootmgr} device partition=\Device\HarddiskVolume1

  1. I fixed the default boot record as follows

BCDEDIT /set {default} device partition=C:
BCDEDIT /set {default} osdevice partition=C:

  1. I removed the Windows DVD and restarted the VM in Hyper-V.

Now it worked fine and on a 40GB fixed size VHD.

 

GOTCHA #2:

Do not create a dynamic size VHD with the maximum you think. You can always increase its maximum size but it is hard to decrease it.

 

So back to track (and lost another day and half). Changed again my host OS boot record to point to the new 40GB fixed size VHD and restarted my machine and BAM again BSOD. Again tried SYSPREP and no luck still BSOD but with changed error this time. I started in safe mode (maybe I should always start in safe mode the first time) and now it is stuck in loading CLASSPNP.SYS. Again binged the internet and found the problem. My laptop has SATA AHCI enabled and my VM did not have that and by default there is no way this can be changed once the OS is installed (I found a way to do this but did not try it myself on this forum http://forums.pcper.com/showthread.php?t=444831 – it seemed too risky anyway and frankly I was getting tired). So I restarted my machine and entered the BIOS utility and disabled AHCI. Booted in my VHD FINALLY it worked.

 

GOTCHA #3:

If VHD booting is stuck at CLASSPNP.sys while booting in safe mode disable SATA AHCI or change it to compatibility mode.

 

Oh and one final note, I did NOT perform SYSPREP and it worked like charm.

  • Thanks, been hitting my head on the wall for 2 days before finding this article.  I was moving over a number of diffenent VHD's to my new laptop and the VHD's always came up with a BSOD.  Tried everything and what was strange was that the VHD's worked in the Hyper V 2008 booting from the laptop...

    "So I restarted my machine and entered the BIOS utility and disabled AHCI. Booted in my VHD FINALLY it worked. "

    That was the trick that fixed the issue.

  • Thank you so much for posting this.  I've been struggling with gotcha #3 and changing from AHCI to compatibility worked like a charm.

  • I don't think I have the same luxury as Jon and yourself. My BSOD win2008R2 vhd runs fine when in native boot ... but ported to windows 8 Hyper-v ... I found I needed recreate the boot partition msmvps.com/.../moving-a-vhd-boot-disk-to-hyper-v.aspx

    . I will try again but I seem to remember hyper-v stopped working....

  • Yep I can confirm when I switch to IDE mode in the bios of my laptop .. Windows 8 does not boot up. I guess I need to move to your plan b and enable AHCI on  the windows on either the original VHD or my modified VHD that is hosted in win 8 hyper-v but can only boot via win2008r2 media.

Page 1 of 1 (4 items)
Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post