Converting a ThinkPad T410s Optimus from Physical -> Native Boot from VHD

windows7rc_bloglogoLike a lot of other folks, I’ll be attending the MVP Summit.  I contemplated which laptop to take.  I have a number of options but unfortunately the machine I want to take is my personal ThinkPad T410s.  It’s slightly over three pounds, has a powerful dual core i5 processor, lots of memory, a fast SSD for the primary drive, and the fabulous Ultrabay where I can host a second hard drive.  Did I mention light?  Yea, it’s about a third of the weight of my W510 and brick.

In order to use my T410s, I have to solve a number of issues.  The most annoying issues are the corporate requirements to use the network.  The machine must be joined to the domain to integrate well with the IPSEC boundaries.  I need that next week.

Now technically there is a guest network I could use but it’s a bit of a hassle and I really need to be on the corporate network anyway.  So I pulled out the Intel 1.8” SSD and popped in my Crucial C300 and started installing Windows 7.  After I got things pretty well cooked, I realized this isn’t what I want to do at all.  What I really want to do is run a multi boot environment so I can also bounce into Windows Server and Hyper-V, too. But I don’t want to throw away my Windows 7 install and work.  What to do?

P2V to the Rescue

You’ve likely heard the term P2V.  Normally this means converting a physical machine to a virtual machine.  This is common for aging hardware where you want to continue to use the software environment.  That sounds just like to ticket for me.

Technically I’m not really converting my physical machine to a virtual machine.  What I’m really doing is capturing the OS, applications, and my user data then stuffing it all inside a virtual hard disk file (VHD).  Later, we’ll make it bootable and usable but we aren’t using a hypervisor, and aren’t emulating hardware.

The upside and benefit to this approach is that I can still take advantage of the physical hardware and it’s full fidelity and speed, but encapsulate it inside a single file that is very reusable and portable.  How?

Sysinternals Disk2Vhd

There are a number of utilities and methods to capture a physical machine.  I decided to try the Disk2vhd program from the Sysinternals TechNet site. I downloaded it, unpacked it, took a quick look at the .CHM helpfile then let it rip.  I told it to capture drive C: and create a VHD on an external eSATA drive and enclosure.

There are a number of considerations to think about.  First, the Disk2vhd tool will create the target VHD as a dynamic disk VHD and size the allocation equal to the source physical drive.  There’s a problem with that.  Because the source in the case was a 128GB SSD drive, when the new VHD is booted, it will expand to that size.  Therefore, the storage device that is used to store the VHD must always have at least 120GB of free space even though the VHD is only using 44GB at present.  I am not a big fan of this and hope it changes down the road.  The storage device in this case is 2.5” Hitachi 500GB 7200rpm hard drive and has 250GB of free space.  Plenty of head room for now.

Second, there are disk signature implications.  The impact area is the BCD store so you must be careful if you intend to continue using the source disk with the new VHD.  In my case, the Crucial C300 used as the physical source is not present because I pulled it back out, and I am using the Intel 160GB SSD.  The moral of the story, pay particular attention to the before and after of your BCD store entries.

After I captured and created the VHD, there’s only a couple of easy steps to get this setup and working the way I want.

BCDBoot to the Rescue

The next step I wanted to accomplish is moving the resulting VHD file from the external eSATA drive and enclosure to the internal ThinkPad Ultrabay hard drive adaptor and drive.  This is of course a simple copy.  But the real fun comes next.

Like some of the other native boot from VHD articles I’ve written, Windows has a nifty command line utility for adding entries to the BCD store and making them available at boot time.  So all I need to do was mount the VHD and use BCDboot to do that. Here are those steps:

  1. Press the Windows key on your keyboard or click the Windows 7 start pearl at the far left of the task bar.
  2. Right mouse click Computer.
  3. Select Manage from the context menu.
  4. Click the Disk Management snapin in the left nav.
  5. After it has initialized, Click the Action menu at the top of the MMC console shell.
  6. Click the Attach VHD menu item.
  7. Browse to the location of the VHD and select and open the VHD.  In my case, this is D:\Win7\KEITHCOT410s.vhd.  Make sure to note the drive letter that is assigned.  Mine is E:
  8. Open an elevated CMD console.
  9. Enter BCDBOOT E:\windows
  10. Exit the CMD shell.
  11. Reboot Windows 7

You’ll notice the new entry has been added and available when your machine reboots.  Now you can easily flip between your personal environment and a corporate desktop.  The last add to the BCD store becomes the default boot environment and unless you adjust the descriptions, they will have the generic “Windows 7” or “Windows Server 2008” descriptions for the entries.  I always tweak those settings so I can easily tell the difference.

For instance, BCDEDIT /set {current} description “Windows 7 (Corporate)” is the command I used to reset the description for this BCD store entry.  {current} is valid if it’s up and running.  If it isn’t, use the long GUID in the curly brackets.

Now keep in mind I started with an environment that was built on the same machine.  If it’s different, keep in mind you may need to sysprep and go back through device detection.  It really depends on the source and target.  For this example, I didn’t need to worry about such matters.  Pretty kewl, eh?  Enjoy.