Creating bootable usb vhd

You can create a vhd which is entirelt bootable from a USB stick.

Notes:

  1. Only works with Win7 Ultimate or Server 2008 R2 (or later)
  2. The vhd will be dependent on the hardware of the machine it was built on (in terms of drivers etc).  This is NOT a completely independent vhd like Hyper V
  3. HyperV vhd images can not simply be moved without having the drivers for the generic HyperV hardware replaced

Tools:

Steps:

  1. Create a bootable USB from an ISO using ISOtoUSB (Note some ISO’s seem to error giving a message about a missing DVD/CD driver.  Some say this is down to a bad ISO – I found some worked and some didn’t)
  2. Boot from USB ISO (detailed instructions here http://blogs.msdn.com/b/knom/archive/2009/04/07/windows-7-vhd-boot-setup-guideline.aspx)
  3. Go through setup screen to the Install screen
  4. Press Shift F10 to get to DOS window
  5. Enter diskpart to start the partitioning utitlity.
  6. Create a new VHD file by entering
    create vdisk file=”D:\pathToVhd.vhd” type=expandable maximum=maxsizeInMegabyte
    Note: MaxSize even on an expandable disk – must be less than the space available on the USB disk (as it checks and will fail if there is not enough room)
  7. Now select the new VHD and attach it as a physical disk.
    select vdisk file=”D:\pathToVhd.vhd”
    attach vdisk
  8. After that switch back to the setup window (e.g. using ALT+TAB) and start the setup.
  9. Proceed the normal setup, but make sure you install to the correct disk (normally the last one), ignore the “Windows cannot install to this disk” warning!!
  10. Boot into your normal OS and load the VHD as an extra drive (from computer management)
  11. Correct  usb boot drivers: set_7_usb_boot.cmd h:\windows
  12. Detach vhd
  13. Copy vhd to USB
  14. Use EasyBCD to set USB boot to be the VHD

Useful refs:

http://johndandison.com/blog/post/2010/02/25/Boot-to-Windows-7-VHD-with-a-Portable-USB-BCD-Bootloader.aspx

This may allow you to get a bootable VHD to also function as a HyperV VM:

http://social.technet.microsoft.com/wiki/contents/articles/159.how-to-convert-a-vhd-bootable-image-into-hyper-v-vm.aspx

Scenario
 
You have a VHD used to boot your PC or server (see Boot from VHD). You need to make this VHD bootable as Hyper-V VM.
 
Solution
 
This would not work by default. You will need to execute the following sequence of tasks.
 
Note: the following sample commands assume that you mount your VHD as disk F:
1.Turn off the VM (if was running) and mount VHD to some working OS (e.g. your host OS).
2.Make the Partition Active.
3.Run: bcdboot c:\windows /s f:
4.Run: bcdedit /store h:\Boot\bcd /set {bootmgr} device hd_partition=H:
5.Run: bcdedit /store h:\Boot\bcd /set {default} device hd_partition=H:
6.Run: bcdedit /store h:\Boot\bcd /set {default} osdevice hd_partition=H:
7.Load “System” registry hive from OS located in VHD (i.e. Regedit -> Load Hive -> select “F:\Windows\System32\Config\System”)
8.Change startup mode for “IntelIDE” driver from “3” to “0”. (That may be alrady the case depending on how you OS boots in Boot from VHD scenario).

Comments

Comments are closed on this post.
Find out more