Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Virtual Hard Drive VHD File - Create and Start with at Boot


26 Jan 2009   #19
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 
Virtual Hard Drive VHD File - Create and Start with at Boot

How to Create a Windows 7 VHD at Boot to Start with from Boot

...

My System SpecsSystem Spec
.

18 Mar 2009   #20
pitajax

Windows 7
 
 

OK, I understand that. Thank you very much.
Nice place you have here
Quote   Quote: Originally Posted by Brink View Post
Hello Pitajax, and welcome to Seven Forums.

As Spacesurfer posted, you can place the VHD at any location. You will just need to modify the commands in the steps for that location instead.


My System SpecsSystem Spec
.

18 Mar 2009   #21
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

You're welcome Pitajax.
My System SpecsSystem Spec
18 Mar 2009   #22
spacesurfer

Windows Vista and Windows 7 Beta
 
 

Some info regarding booting Windows XP from VHD.

It seems that it should be possible as XP does have the VHD drivers. When you install XP in a virtual pc and attach a second VHD drive, you can see device manager loading the drivers for virtual drives. Hence, my theory is that it should be possible to boot XP from VHD.

Based on this premise, I have tried the following ideas (and if someone wants to further test different scenarios, that would be helpful):

1) Install XP on Virtual PC VHD
2) Add VHD boot entry to menu

bcdedit /set {ntldr} device vhd=[drive]\file.vhd
bcdedit /set {ntldr} osdevice vhd=[drive]\file.vhd
bcdedit /set {ntldr} detecthal on

3) Try to boot XP and get an error stating NTLDR not found

Based on above, it seems the VHD does load but it can't find ntldr within the partition.

So, I tried the following. Instead of loading XP using ntldr, I tried loading it via bootmgr by doing the following:

1) Export bcd store from a bootable source. Import that in XP loaded in Virtual PC.
2) Copy bootmgr, bcdedit, and bootsect.exe to XP in virtual pc.
3) Change bootsec from nt52 to nt60 using the command bootsect /nt60 /f
4) Copy bootmgr to c:\
5) Add entries to boot XP
6) Restart to make sure XP boots using bootmgr instead of ntldr. It does and I have succeeded up to here.
7) In main physical OS, add entry to boot to this VHD that load XP using bootmgr instead of ntldr.

This failed for me. Instead of loading XP, I got Windows 7 recovery... and vaguely remember some error about partition not being right.

So the plan is to format the partition with Windows 7, then install XP on that and retry.

So, here's the steps if anyone wants to try.

1) Create a virtual pc vhd. Load Windows 7 iso and format the partition with windows 7. Abort win 7 install. (Or use command prompt and diskpart to format and exit).
2) Load Windows XP iso and install windows xp.
3) change boot loader to bootmgr as outlined above.
4) add boot entries to menu
5) load xp.
My System SpecsSystem Spec
10 Apr 2009   #23
enigmae

win 7 rc
 
 
save a couple steps

I found that during install you can press Shift+F10 it will pop up a command prompt. So you can essentially skip the whole navigate to recover stuff and just pop into cmd and do diskpart, from diskpar screen.

I tested out a Windows 7 to Windows 7 dual-boot it is installing as i type this. I have used this to play solitar, majohng, or minesweeper while it is installing/upgrading with no issues (i even managed to get IE to work while upgrading but the upgrade took 3+ hours)

good luck.

Lucas
My System SpecsSystem Spec
10 Apr 2009   #24
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Hello Lucas, and welcome to Seven Forums.

Thank you. It has been added.

Shawn
My System SpecsSystem Spec
12 Apr 2009   #25
unawave

Windows XP and 7
 
 

Quote   Quote: Originally Posted by gencode View Post
Id like to format my primary hd and back up my new vhd to my NAS drive, then put it back when im all done.
I know I can copy it back, but how to I attach it to the boot menu? so it can be booted after I reformat my primary drive or if I were to upgrade to a new larger drive.
You need to install the boot manager. Because you do not have any operating system on your clean hard disk you can not use "system repair".

So: Install a "dummy" operating system:
Format your hard disk with NTFS
Boot from Windows 7 DVD and install Windows 7 to VHD file. See here.


After this you have on your hard disk:
  • The VHD file
  • Boot manager as file "bootmgr"
  • Boot settings in folder c:\boot\bcd
  • A file "pagefile.sys"
Boot this "dummy" installation.

You now should see two hard disks:
  • C: = dummy VHD file
  • D: = real hard disk
Copy your backup of your VHD file from NAS drive to D:
Then use "bcdedit" to add boot menu entry of your (backup) VHD file. See here.

Boot to your (backup) VHD.
If it works all fine then you can delete boot menu entry of your "dummy" installation via "bcdedit" and also delete dummy VHD file.
My System SpecsSystem Spec
13 May 2009   #26
uder

Vista/7
 
 

Thanks for this guide, it worked perfectly.
However I have had a lot of driver problems with Windows 7 (very old hardware) and would like to now remove it. Do I just follow the tutorial: How to Unattach and Delete a Virtual Hard Disk in Windows 7, as posted at the top this guide under related links?

Also, how does one go about changing the default boot OS? Atm its Windows 7 but I may want to switch it the existing OS instead of remove it.

Cheers.
My System SpecsSystem Spec
13 May 2009   #27
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Hello Uder, and welcome to Seven Forums.

I have added OPTION TWO to the tutorial to help show you how to.

To just change the default OS to start to, this tutorial below can help show you how to.

Default Operating System - Change Default Boot OS

Hope this helps,
Shawn
My System SpecsSystem Spec
30 May 2009   #28
Oblomow58

Win7 x64 SP1, Virtual Hackintosh
 
 
Type of the VHD-File: Fixed vs. Expandable

It is an excellent documentation offered here in that forum, and I successful installed Windows 7 x86 RC on my Thinkpad z61p using a USB-Stick as a installation media and a VHD as installation target.

But on question / problem came up, the size of that VHD-File for a full Windows 7-installation and Office etc.

Diskpart offeres two types of VHD-Files, FIXED (Default) and EXPANDABLE.

DISKPART
CREATE VDISK FILE=C:\VHD\<filename>.vhd MAXIMUM=25000 TYPE=EXPANDABLE

In FIXED mode (as I understand) the max value will be allocation right now, the size will be 25Gig. In EXPANDABLE mode the size will be that amount of data, which is used by the installation, not more and the size at all can grow up to 25 GB (same behaviour as with Virtual PC or VMWare Workstation).

So I selected a MAXIUM of 100 GB thinking the effective size will be just around 15-20 Gig. But as I looked into the explorer, the file is 100 GB in size and the underlying Vista installation has a lack of free disk space now.

I cannot see any difference in the allocated size of my VHD, but I have created it with the TYPE=EXPANDABLE option and diskpart reports the Type as expandable - But the size is fixed to the maximum.

Does anyone here has similar experiences?
Is there a method to shrink the VHD?
What about a comparison in using a VHD vs. shrinking Vista and using a own partition for Windows 7?
What about Hypernation in a VHD?

Lots of questions

Greetings from Switzerland and Thanks in Advance

Oblomow
My System SpecsSystem Spec
31 May 2009   #29
Brink
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

Hello Oblomow,

Sorry for the late reply, but it took a bit to play with this to see what options may be available for you.

I have added a option to create either a fixed or expandable VHD file option to help give more options.

When using the type=expandable command, the VHD file will be exandable, but it will require installing Windows Virtual PC to actually see the VHD file as the smaller expandable size instead of the full fixed size. It seems that without that program installed to have associated with VHD files types, Windows 7 will still only show the maximum size instead whether it is fixed or expandable.

I find that it's usually best to backup anything on the VHD that you did not want to lose, then delete it and create a new VHD file the size that you wanted instead of trying to shrink an existing one.

Hope this helps,
Shawn
My System SpecsSystem Spec
Comment

 Virtual Hard Drive VHD File - Create and Start with at Boot




Tutorial Tools



Similar help and support threads for2: Virtual Hard Drive VHD File - Create and Start with at Boot
Windows 7 Tutorial Category
Can i boot from a VHD (Virtual Hard Drive) Virtualization
A Virtual Hard Drive? Two separate hard drives now run Win 7 x64 Backup and Restore
WEI fails (cannot write file to hard drive) Boot drive set to B:\ Performance & Maintenance
virtual hard drive Hardware & Devices
Virtual Hard Disk - Create and Attach VHD Tutorials
Is it necessary to defrag a virtual hard drive? Virtualization
Can't start up hard disk image in Virtual PC RC Virtualization

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 04:59 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33