Boot to VHD: Create VHD from Command Line

By Michael Flanakin @ 6:40 PM :: 7187 Views :: Technology, Tools/Utilities :: Digg it!

Windows 7

Virtual PC is great. Well, it's ok -- it does the job. There's a better way, tho, and that better way is to just get rid of the host OS... or, ask the OS to politely let you get by for a while. That's exactly what Windows 7 does by enabling you to boot into a VHD.

Scott Hanselman Syndicated feed blogged about booting from a VHD in more detail, but I wanted to break it down into discrete steps. For simplicity, I'm going to start from scratch, creating a VHD from the command line.

  1. Put Win7 or Server 2008 R2 DVD or bootable USB drive in
  2. Restart your computer
    NOTE: You'll need to be sure you can boot using the necessary device in BIOS settings (obviously)
  3. Press any key to boot from CD or DVD
  4. When the Install Windows screen is shown, press Shift+F10
  5. Type d:, press Enter
  6. Type md machines, press Enter
  7. Type diskpart, press Enter
  8. Type create vdisk file="c:\machines\win2008r2.vhd" type=expandable maximum=50000, press Enter
    NOTE: Be sure to set a maximum your machine can support; Windows will temporarily expand the VHD to that size when you boot into it
  9. Type select vdisk file="c:\machines\win2008r2.vhd", press Enter
  10. Type attach vdisk, press Enter
  11. Type exit, press Enter
  12. Type exit, press Enter
  13. Click Next
  14. Click Install Now
  15. Select desired OS (server only), click Next
  16. Check I accept the license terms, click Next
  17. Click Custom (advanced)
  18. Select Disk 1 Unallocated Space (...GB)
  19. Click Drive options (advanced)
  20. Click New, then Apply
  21. Click Format, then OK
    NOTE: If you see a "Windows cannot be installed to this disk..." error, ignore it.
  22. Click Next and continue to install the operating system as you normally would

After the installation completes, Windows Boot Manager will give you an option to boot into either the host or guest OS instances. Gotta love it!

Ratings