Windows

How to install Windows Server 2008 R2 with Hyper-V and Windows 7 on the same partition

Blogger Colin Smith explains how to install Windows Server 2008 R2 with Hyper-V and Windows 7 on the same disk partition by booting from a VHD that contains the entire WS2K8R2 OS within a single, portable file.

Typically, dual-booting multiple operating systems requires repartitioning a disk, which isn't always desirable, especially if you already have a multi-boot environment with Windows and Linux. What I am proposing is booting from a VHD - a virtual hard disk that contains the entire Windows Server 2008 R2 OS installation within a single, portable file hosted by your Windows 7 file system.

What's different about this post from the other boot-from-VHD posts out there? Admittedly, I did learn how to create and install into VHD from some of the TechNet posts, but they focus on creating VHDs from within the WinPE console. Unfortunately, most of us work in Windows, not WinPE. So, what I have attempted here is to show you how to create the VHD from Windows 7 (or Windows Server 2008 R2), so that you can create VHDs for other purposes in addition to just an OS install. Additionally, I'll try to provide some other scenarios where you might want to consider using VHDs.

Why would you want to boot from a VHD?

There are several reasons:

  • There is no requirement to repartition your hard drive, which in itself tends to waste disk space since most partitions are typically over provisioned.
  • It simplifies image management for both VMs and physical systems as the same VHDs can be repurposed for both use cases.
  • You can move the VHD to a Hyper-V server or port it to another virtualization platform like ESX, Virtual Box, Xen , etc., that supports VHDs.
  • The VHD can be configured to be thin provisioned. This means that you can set the maximum size of the VHD and it will appear to the guest OS as a full partition, but in the host OS, it will only consume as much disk space as required to contain the entire guest OS. The VHD will grow in size up to the maximum as blocks are written to (allocate on write).
  • You can remove the entire OS by simply removing a single file and updating your boot menu.
  • It allows you to boot easily from an external device like an eSATA drive (USB or remote storage are not supported for Windows 7 or Windows Server 2008 R2 - Hyper-V Server is supported on USB/Flash )
  • You can easily back up the entire OS as a single file (like you would a VM).
  • You can have versioned OSs using a differencing disk to create a parent child relationship between VHDs. This can be very disk space friendly if you manage many images.

What you'll need:

Note: In the examples below, I am doing everything on drive C: and assigning drive letter Q: to the VHD but you can use any drive that Windows 7 has available.

Preparing the VHD

First we'll need to create a VHD on the Windows 7 system using the DISKPART command:

1.       From the Start->All Programs->Accessories right-click the Command Prompt and select "Run as Administrator" - DISKPART will launch and you will be put into the DISKPART CLI shell.

2.       Let's have a look at what volumes DISKPART can see. Type:

list vol

Take note of what you see.

3.       To create a minimal size VHD that can grow to a maximum size of 15000MB type:

create vdisk file=c:\win2k8r2.vhd maximum=15000 type=expandable

4.       To set the focus of DISKPART to the newly created VHD type:

select vdisk file=c:\win2k8r2.vhd

5.       To attach the virtual disk to the system type:

attach vdisk

6.       We will need a primary partition within the virtual disk to make the VHD bootable; type:

create partition primary

7.       Although the partition can be formatted as part of the Windows Server installation, I prefer to do it now. To format the partition with the NTFS file system, type:

format fs=ntfs quick label="NewVHD"

8.       We don't really need to assign a drive letter to the VHD at this point since during the install of Windows Server, it will get a different drive letter anyway, but it makes it more convenient to investigate the VHD from Windows 7. Assign the drive letter Q: to the new partition by typing:

assign letter=q:

9.       Let's have a look at what volumes DISKPART can see now.  Type:

list vol

You should see the new volume available with a size of 14GB.

10.   To exit the DISKPART shell type:

exit

11.   To exit the command  shell type:

exit

12.   Use Windows Explorer to see what size the file c:\win2k8r2 that contains the VHD is. It should be around 80MB. It will grow from here as we add contents to the volume.

13.   For fun use right click Computer from the Start Menu and you should see drive Q: mounted. You can check the properties of drive Q: by right clicking it.

Installing Windows Server

Now we are ready to install Windows Server 2008 R2 onto the newly formatted partition within the VHD. I'll provide general instructions here, just highlighting the differences from a standard installation.

1.       Boot from the Windows Server 2008 R2 ISO. At the screen that prompts you to select a language press SHIFT+F10 to access the WinPE console.

2.       To launch the DISKPART CLI shell:

diskpart

3.       Let's have a look at what volumes DISKPART can see. Type:

list vol

4.       To set the focus of DISKPART to the previously created VHD, type:

select vdisk file=c:\win2k8r2.vhd

5.       To attach the virtual disk to the system, type:

attach vdisk

6.       Let's have a look at what volumes DISKPART can see. Type:

list vol

7.       To exit the DISKPART shell, type:

exit

8.       To exit the WinPE shell, type:

exit

9.       Return to the Windows Server 2008 R2 setup and select Custom (advanced) as the installation type, not Upgrade.

10.   When prompted for the installation location, select the newly formatted volume that has the label NewVHD.

11.   Perform the remainder of the installation as usual.

12.   When you reboot you will notice that you get a boot menu allowing you to select the OS of your choice. Select Windows Server 2008 R2.

13.   Turn on the Hyper-V role.

Now you have a dual boot Windows 7 and Windows Server 2008 R2 system that can also run the Hyper-V role even though it is not installed in its own partition of a physical disk.

At this point, you could migrate your Windows 7 installation to a VHD so that both of your operating systems are booting from VHDs. If you choose this route, the Disk2vhd tool might prove useful.

You could also use the VHD that you just installed Windows Server into as a Hyper-V (or ESX) virtual machine (you will need to recreate or modify the BCD store first).

By the way, the size of the VHD you created will probably be around 6 GB when viewed from the Windows 7 instance.

Get the PDF version of this tip here.

About

Colin Smith is a Microsoft SCCM MVP who has been working with SMS since version 1.0. He has over 20 years of experience deploying Microsoft-based solutions for the private and public sector with a focus on desktop and data center management.

23 comments
nrasu
nrasu

I have tried this method on a ProBook 6560B and I am getting the following error

"The selected partition requires at least 7667 MB free space".

Windows cannot be installed to this disk. This computer hardware may not support booting to this disk. Ensure that the disks controller is enabled in the computer BIOS menu.  (Dual Boot works on it...but I wanted to try it this way)

khizerishtiaq
khizerishtiaq

Hey... i followed the whole procedure till the end ...and it worked fine for me... but it doesnt seem to detect my intel drivers...even if i manually locate them on my harddisk....specially for internet and sound....every time i try to install..it says no network adapter found... i am using alienware m15x ....and the network and wireless adapter seems to work just fine in windows 7.... do you know why it is causing the problem?? Another thing i wanted to ask is will it support clustering PCs? since the main reason for me to install this windows was to establish a cluster connection btw my alien-ware n desktop for more processing power on my graphics work... Looking forward to for your help... Hope to hear from you soon... Khizer

rux
rux

Using you instructions now I have a Win7 and Win2k8R2 dualbooting PC. I would like to launch Win2k8R2 from Win7, so i tryed to create a VM using my Win2k8R2.vhd and I get always the same error unable to start because I'm using a read only VHD. Tryed with these Hypervisor: Virtual PC, Virtual Server, VirtualBox and alway got this error. Any idea?

navincshetty
navincshetty

Its a easiest tute I found on net, but my bad i wasnt successful. Till end of forst part everything was went exactly as you mentioned, but after restarting my VHD was not there, I tried two time.. please any suggestions???

ChrisHyche@AlabamaOne.Org
ChrisHyche@AlabamaOne.Org

Would this allow you to run 2008 in Hyper-V while running 7 as a native client (to the hardware)? What I am getting at is I would like 2008 to be able to run together with Win7 but I need Win7 to have full hardware support (3d video, sound, etc.). I know I can use VPC but that seems like a lot of overhead. It has been something I have been hoping for ever since Hyper-V came out.

Justin James
Justin James

In my mind, other than for testing purposes, W2008R2 is an "always on" system, especially if it had Hyper-V installed. For testing apps and such, I'd run it in a desktop VM system which will give me better utilities (like snapshots). J.Ja

davidsmi
davidsmi

That is a pretty cool trick - - and one that you would have to be a deeply perverted geek to think of. But from a technology point-of-view I think you could do the whole thing with many less steps. 1) Using "Disk Management" shrink one of your existing volumes - this is part of Windows 7 (included in Vista too) 2) Install Windows Server first - then just run your Windows 7 as a Hyper-V machine. What's the advantage of creating the vhd file vs. shrinking your existing volume or running as a virtual machine?

teeeceee
teeeceee

As with navincshetty, the vhd partiton disappeared on restart to install WIN2008R2. I can reselect it using diskpart during the install, but it does not appear at all in the choice of drives in the install screen. I tried deleting it and doing the disk part config during the installation, and got as far as installing the files, but then it bombed out there (at step 2) wanting a network connection. Since then, I cannot even repeat that procedure with any success. Any help? TEECEE

The Colin Smith
The Colin Smith

and I'll try to help. send to me by clicking "Send Message" at the bottom of this comment.

The Colin Smith
The Colin Smith

Do you want to run Win7 on bare metal and Hyper-V simultaneously? If so then the answer is no. You can run Windows 2008 as a Hyper-V VM but either Hyper-V Server of W2K8R2 with the Hyper-V role turned on needs to be on bare metal. The method described here allow dual booting Win7 and W2k8R2/Hyper-V.

techrep1000
techrep1000

but has a place for testing and demos where hardware might be scarce.

fallout330
fallout330

I thought the same JJ, good point.

The Colin Smith
The Colin Smith

In an ideal world, I'm all for running your Windows 7 desktop as a VM. But as with most type 1 hypervisors, driver issues abound on non-HCL platforms. For instance, although I can run hyper-v on my notebook (Toshiba Satellite Pro i5), W2K8R2 doesn't fully support my video card so I can't connect to a remote display device like a projector. Since I often do PowerPoint presentations this is a problem for me. Secondly, shrinking your volume still has the disadvantage of potentially over-provisioning your second partition - also remember that Windows 7 only allows 4 primary partitions and one is already used for the hidden WinRE partition, so you only have 2 more to play with. You might want those for an OS that doesn't support VHDs. The VHD is so much more portable than installing on a new partition/volume. BTW - since you like Disk Management, you could always create your vhd from the Action menu but that hardly seems as deeply perverted or geeky as using Diskpart.

rux
rux

Thank's Joe, my problem is that the VHD is already there and I would like to keep it as it is. I have created it trough diskpart and then installed W2k8 on it trough a normal installation. But I'm not able to use it in any Virtual enviroment because of this readonly mode. I wonder if and how is possible to take this vhd in writable mode.

rux
rux

Launched as Administrator, as you suggested, now I got a clear message about vhd wrong format. It seems Vbox (and Virtual PC as well) don't support this VHD.

jgiessner
jgiessner

rux@ - I have 4 thoughts of things to try on this, and this is the order that I suggest you try them: 1. Run your VM program as Administrator. I had a similar problem with VirtualBox using a VHD in the root directory -- I ran VBox as Administrator and it solved that problem. 2. Try moving the VHD to another directory that has "liberal" permissions to all users. 3. Validate that the Read-Only flag on the VHD file is not set. Also manually set the security on the VHD file to allow full access to everyone (just for testing purposes). 4. If all of the above fails, I would suggest cloning the VHD and trying to use the clone. Using VBox as an example, you would use the "VBoxManage clonehd" command to clone it. Just making the clone may work for you. If not, there is also, "VBoxManage modifyhd" where you can set the "type" of VHD, which includes read-only options. That's about all I have in my bag of tricks.

ChrisHyche@AlabamaOne.Org
ChrisHyche@AlabamaOne.Org

I ran across VitualBox yesterday which is supposed to have some experimental Direct3D 9 and OpenGL support.

The Colin Smith
The Colin Smith

Take a look at what Intel is doing with vPro (VT & TXT specifically) and some of the neat stuff that MochaFive is building. The functionality you want may never appear in Hyper-V but it isn't far off for desktop tech.

The Colin Smith
The Colin Smith

Take a look at what Intel is doing with vPro (VT & TXT specifically) and some of the neat stuff that MochaFive is building. The functionality you want may never appear in Hyper-V but it isn't far off for desktop tech.

ChrisHyche@AlabamaOne.Org
ChrisHyche@AlabamaOne.Org

I would kind of like it to be an option or have the emulation layer robust enough to handle beyond basic functionality. Seems like Hyper-V gets closer to that with the storage controllers but there is still a lot left. Support for 3d acceleration maybe even CUDA, support for some advanced sound or for other devices. Come to think of it some good DirectX support would cover quite a bit (if you can do it fast). That would make a dandy XP-Mode. I do realize that Hyper-V is more intended for a business environment, but I am not the only one to use business tech at home or home tech at work. Even for a business argument. How about Photoshow or AutoCAD running in a VM by itself (maybe even on a different OS but still using acceleration) while you can do other things on your primary OS. I know it would be an impact on the whole machine now but with the multi-cores and large memory amounts it is getting a lot more reasonable. Oh well a man can dream...

The Colin Smith
The Colin Smith

it wouldn't support live migration to dissimilar hardware

Editor's Picks