Quick VHD Install

Illustration

I already wrote about installing Windows 7 (and their Windows 2008 R2 cousin) into VHD (Virtual Disk) file, but there is a quicker way of doing it. You don’t even need to go through installation process.

On MSDN, script appeared that does conversion from .wim files to VHD. As you may know, .wim is extension of Windows Imaging Format that serves as installation image from Vista onward. This script just reads this file and using native Windows 7 VHD mounting (yes, you need to have Windows 7 for this) creates new virtual disk with Windows installed inside of it (only Windows 7 and above). This speeds things considerably since there is no booting inside installation, loading it’s drivers or even answering any questions (for that you need to use unattended answer file).

This tool has much more possibilities that described here (e.g. applying of patches) but I will go only into installing base system.

Creating virtual disk

In order to create bootable windows you can call script (in elevated prompt - administrator rights are required):

cscript.exe WIM2VHD.wsf /wim:X:\sources\install.wim /sku:ULTIMATE /vhd:"D:\Virtual Machines\Native\Windows7.vhd" /size:20480 /disktype:Fixed
...
INFO: Inspecting the WIM...
INFO: Creating a Fixed VHD. This can be a time consuming process...
INFO: Configuring and formatting the VHD...
INFO: Applying the WIM... [ 100% ] Applying progress
INFO: Making the VHD bootable with BCDBoot...
INFO: Unmounting the VHD...
Summary: Errors: 0, Warnings: 0, Successes: 1 INFO: Done.

Notice that here X: is Windows 7 installation disc (or Windows 2008 R2, works the same).

Only required parameters are /wim and /sku, but I wanted to include /vhd, /size and /disktype in order to make same .vhd file like in original post. Do be carefull since it overwrites without any questions.

If you are wondering how to find which /sku value you should use, you can check which ones are available with:

cscript.exe WIM2VHD.wsf /wim:X:\sources\install.wim
...
************************************************************
Error: 0: The supplied WIM does not contain a(n) "UNSPECIFIED" image.
Possible images are:
HOMEBASIC
HOMEPREMIUM
BUSINESS
ULTIMATE
************************************************************
...

Booting

In order to boot from this disk image, you need to work a little with bcdedit. I will not describe it here since it is same procedure as booting from any other VHD file. For booting inside of Hyper-V or Virtual PC, there is no need for any action other that attaching VHD to virtual machine.

Something else

Don’t forget to install Windows Automated Installation Kit. If you do forget, you will get rather unhelpful message (Error: 0: No filePath was specified. This file was marked as critical.) and script will refuse to do any work. This same message will appear if imagex.exe cannot be found (usually at C:\Program Files\Windows AIK\Tools\amd64 or C:\Program Files\Windows AIK\Tools\x86). Just put it in PATH environment variable and you will be fine.

Is it any good?

Whole process took around ten minutes. Installation step took only four minutes (rest was creation of fixed VHD) which is much faster than DVD based installation. It does leave you at Out of Box Experience (some five minutes more), but if you really need speed, you can prepare answer file and that step is gone.

If you need to install Windows 7 into VHD (not only on your native system but also for use with Hyper-V or Virtual PC) this is a way to go.

[2009-05-13: Updated with Windows 7 RC links]

Fixing Bootable VHD

Illustration

I have installed Windows 7 to VHD (Virtual Disk) file a while back now. I did like it, so I killed Vista and decided to install Windows 7 on my primary partition also. During installation of it, I formatted boot partition. Unfortunately, that also killed any possibility to boot into Windows 7 system within virtual disk file.

In order to boot from this disk image, some play with bcdedit is needed (in elevated prompt). First we need to discover identifier of our original installation (marked red in following text). Once we have it, we can make a copy and perform all further editing on newly created entry (marked blue). Then we set device and osdevice settings. With that step, we are ready for booting. Here are exact commands that worked for me:

C:\bcdedit /v
...
Windows Boot Loader
-------------------
identifier       {2fae45a6-f1ca-11dd-bde6-c5438ada3082}
device           partition=C:
path             \Windows\system32\winload.exe
description      Windows 7
locale           en-US
inherit          {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {2fae45a7-f1ca-11dd-bde6-c5438ada3082}
recoveryenabled  Yes
osdevice         partition=C:
systemroot       \Windows
resumeobject     {2fae45a5-f1ca-11dd-bde6-c5438ada3082}
nx               OptIn


C:\bcdedit /copy "{original_id}" /d "Windows 7 VHD"
The entry was successfully copied to {2fae45a9-f1ca-11dd-bde6-c5438ada3082}.

C:\bcdedit /set "{new_id}" device "vhd=[D:]\Virtual Machines\Native\Windows7.vhd"
The operation completed successfully.

C:\bcdedit /set "{new_id}" osdevice "vhd=[D:]\Virtual Machines\Native\Windows7.vhd"
The operation completed successfully.

C:\bcdedit /v
...
Windows Boot Loader
-------------------
identifier       {2fae45a9-f1ca-11dd-bde6-c5438ada3082}
device           vhd=[D:]\Virtual Machines\Native\Windows7.vhd,locate=custom:12000002
path             \Windows\system32\winload.exe
description      Windows 7 VHD
locale           en-US
inherit          {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {2fae45a7-f1ca-11dd-bde6-c5438ada3082}
recoveryenabled  Yes
osdevice         vhd=[D:]\Virtual Machines\Native\Windows7.vhd,locate=custom:22000002
systemroot       \Windows
resumeobject     {2fae45a5-f1ca-11dd-bde6-c5438ada3082}
nx               OptIn

If you moved image from another system and you with to boot from it, you may also need to turn on HAL detection:

C:\bcdedit /set "{new_id}" detecthal on
The operation completed successfully.

At this point, there is nothing more to do. You may restart and boot into your favorite VHD.

[2009-05-17: Adjusted bcdedit commands so they work both in cmd.exe and in PowerShell]

Bluetooth on Windows Server 2008

Illustration

One of things that differs Windows Server 2008 from Windows Vista is lack of bluetooth. For some reason it was decided somewhere is Microsoft that bluetooth is not a feature for server operating system. While I may partly agree that on real server there is no need for bluetooth, one needs to remember that before anything gets installed on production servers, it needs to be tested. Usually that testing is done on any machine that is available. That often is just some old workstation or notebook. Those computers often do have bluetooth and, since testing can last for few months, sooner or later some bluetooth device comes up.

There is option of installing bluetooth stack from your bluetooth manufacturer. But, not only those stacks are little bit overkill for just connecting your mouse, most of devices these days lack the CD with stack altogether. Manufacturers got so accustomed on people having default stack installed that they do not bother even creating custom one. Even those that have stack available (Broadcom, Toshiba…), bury it deep inside of website.

Cheating

Another way to get a bluetooth stack is to use Vista drivers. Although for almost all other drivers there is complete compatibility of drivers (in sense that you can install Vista drivers on 2008 and have them working), bluetooth stack cannot be installed directly. Solution is to adapt procedure a little.

On Windows Vista (yes, we need Vista) go to “C:\Windows\System32\DriverStore\FileRepository” directory and start search for “*bth*” (notice star before bth). That will get you quite a few hits. Just copy everything that appears in one folder (do not keep folder structure) and has .inf, .sys or .exe extension (no need for .pnf files). That will give you quite a few files and with subdirectories’ files included (e.g. fsquirt.exe), you have all files. You do not need to worry about duplicate files. One copy of each file will do.

Now you need to edit all .inf files. Just open them all and change any appearance of “NTamd64…1” to “NTamd64…3” (two appearances per file). This tells windows that those files support both desktop and server operating system.

You can go into Windows Server 2008 now and when asked for bluetooth drivers, just give it a path to that directory where all work was done. Drivers will install as normally and you will have your bluetooth working.

Windows 7 Videos

Illustration

Here are some Windows 7 videos that I found useful and educating. They are all from Microsoft’s own Channel 9.

Mark Russinovich: Inside Windows 7

This one is a real gem. It is hard to pinpoint subject since they go all around Windows 7 topics, but if you are a developer or just guy who likes to know technical details - this is video to look. If you are searching for some more details on startup/shutdown workings, there is another video (from Chittur Subbaraman) for you also.

Windows 7 New Taskbar - An Overview

To get a grasp on how exactly new taskbar works, you may wish to see this. If you like this check other videos of same series. They additionally deal with its design, internals and jump lists.

A lap around Windows 7 new Scenic Ribbon

Introduction to ribbon interface. Nothing new for those who already worked with Office 2007. For more technical details, you may want to watch this also.

Larry Osterman: Windows 7 Audio - What’s New

Some changes in area where nobody seemed to have a problem. :)

Windows 7: Find and Organize Part 1 - The User Experience

This one is about new way of organizing things inside Windows 7 (libraries and such stuff). If you are developer, part 2 may interest you.