How to boot from VHD file (Windows 10 Preview)


Although it is now easy to test things in a virtual machine it is still something that require, or work better, on a physical installation. Among other Hyper-V or devices with touch screen.

So now when "Windows 10 Technical Preview" is here it is an appropriate time to go through how to use the VHD files as a disk to install the OS. Which makes it possible to start the OS directly without going through a hypervisor, even though we use a VHD file as disk.
You need to have the Pro or Enterprise version of Windows Vista, 7, 8 or 8.1


 

I will assume that you have downloaded the required ISO file, links can be found in my blog post


Remember that this will work on all modern Windows client and server versions, not only on Windows 10.

If you already have a pre-created VHD file with OS, you can skip down to the section “How to add a pre-created VHD with OS” (remember that "sysprep" must have been run on the OS in the VHD file)

If you have BitLocker enabled, refer to the section "What about Bitlocker»

How to get access to F8 option in Windows 8/8.1

Windows 7/8 now have a "repair" function that cannot be started by pressing F8 during startup. Typically a computer starts into "repair" when needed, but I have seen no problem with this and therefore choose to turn on the old classic F8 function before I make these changes. The reason I turn on this is that I have seen cases where the screen "lock" so that you do not get into the "repair" window, and I have then made it harder for me to fix problems. The solution if you can’t use F8 is to start from a DVD, boot USB etc. with Windows installation files or other troubleshooting tools like Microsoft DaRT

Enabling F8 is done with the following command:

Start “Command prompt” as administrator

bcdedit /set {default} bootmenupolicy legacy


I will then have the option of F8, but with the “old” interface


This can be reversed when you want it with the following command:

bcdedit /set {default} bootmenupolicy standard

If you have installed "Windows Server preview" you cannot reversed to the modern "GUI" if you make this change

Create a VHD file

We are now ready to create the VHD file we will use to start Windows from. This can be done graphically if desired or from the command line with "Disk Part". Disk size and type can be customized. Benefit with "fixed" disk is that it reserves the entire disk space the VHD file can use thus avoiding surprisingly full disk. "Fixed" disk also avoids that the file becomes fragmented over time. The downside is that you often use more physical disk space than you really need.

Disk size (1024 x how many GB you want it to be)

25 GB maximum=25600
50 GB maximum=51200
80 GB maximum=81920
100 GB maximum=102400
160 GB maximum=163840

Disk types

type=fixed
type=expandable

I want to create a VHD in the path «c:\vhd\boot-os», named «Win10preview.vhd», with the size of 50GB, drive letter O: and it shall be dynamic.

The commands to create the VHD file with "Disk Part":

Start “Command prompt” as administrator

Diskpart
create vdisk file=C:\vhd\boot-os\Win10preview.vhd maximum=51200 type=expandable
select vdisk file= C:\vhd\boot-os\Win10preview.vhd
attach vdisk
create partition primary
assign letter=O
format quick label=vhd
exit


Copy the Windows files into the VHD file

Once this is done, it's time to copy Windows onto the O: \ drive, we could have restarted the computer and installed it the traditional way, but we want to do this faster, not to mention not depending on DVD, USB or other installation ways.
I mount the ISO file to drive D: (or use the path to where the file Install.wim is located
)

 
DISM command that must be run is::

Dism /apply-image /imagefile:d:\sources\install.wim /index:1 /applydir:o:\

Add boot option

We now have a drive with Windows 10 ready for use, but we need to customize the startup options to include the installation.

This is done using the command "bcdboot»

bcdboot o:\windows

Change the default boot OS

You may want to make sure that the original operating system is set as default booted OS, and that "timeout" value in the selection of the boot operating system is less than 30 seconds. This is done with command line or graphical in "msconfig".
Just type in "msconfig" or “System Configuration” in the start menu or home screen.Select the tab "boot" and make the desired changes

Remember that when you do this change you must select «Windows Technical Preview» when starting or rebooting the computer when you want to start Windows 10.

BCDboot have an /addlast parameter, but it doesn’t seam to work (at least not on my Windows 8.1)

Windows 10

When we start up on the Windows 10 VHD file we can see that the drive that we connected to our VHD (O: \) have changed to C: \ and the local disks are changed to the following vacant letters.

Then it's ready for you.

If you want to remove everything simply delete the line in "System Configuration" and delete the VHD file if you do not want to save it for later.


 

How to add a pre-created VHD with OS

If you have MSDN benefits you can download a completely configured VHD with "Windows Server Technical Preview". This has the catchy name "en_windows_server_datacenter_technical_preview_x64_vhd_5554157.vhd." This is a Syspreped installation of Windows Server, so that we can use in the same way as the VHD file we created with "Windows 10 Preview". It also means that we can take other VHD VM’s we have created in Hyper-V and Sysprep them to be used in the same way. (you might be able to use them without sysprep)

Let's now have look at how we go about getting this done.

We need to run some of the commands we did use when we create a VHD with content from the install.wim file:

Start “Command prompt” as administrator

Diskpart
select vdisk file= C:\vhd\boot-os\ en_windows_server_datacenter_technical_preview_x64_vhd_5554157.vhd
attach vdisk


The VHD file will get next available drive letter, you can change this if you want to use than another drive letter. With me it was the letter E:

We now need to get this operating system added as a boot option and use the following commands:

bcdboot e:\windows

Multiple VHD files

There is no problem to use multiple VHD files if desired, just follow the guide and you will get 3 og more choices during startup.


What about Bitlocker

BitLocker cannot be enabled in the main operating system (the one installed on the physical disk).

You can turn on Bitlocker in the operating system that starts from the VHD file, it will be just the VHD file that is encrypted so you cannot access the file from the physical installed operating system, without having to mount the VHD file and use the recovery key

Remember to have the recovery key ready !!!

If you do not have computer with a TPM chip you can use USB stick or password instead. This is done as follows (booted into the OS you want to test Bitlocker on):
  • Start «Edit group Policy»
    
  • Browse into «Computer Configuration - Administrative Templates – Windows Components –Bitlocker Drive Encryption – Operating System”
 
 
  • Turn on “Require additional authentication at startup” and mark for “Allow Bitlocker without a compatible TPM”




  • Exit “Local Group Policy Editor” (You don’t have too save, all changes are “saved” continuously)

You can now test out Bitlocker on the installed OS

HAPPY TESTING J

Popular posts from this blog

Installing Android on a Hyper-V virtual machine

MDT: TimeZoneName and index number list