Jump to content











Photo

Boot Win 7 VHD on Bare Metal PC from Empty Drive

vhd bare metal boot win 7 grub4dos

  • Please log in to reply
321 replies to this topic

Poll: Are you interested in booting Windows from VHD? (86 member(s) have cast votes)

Would you try to install OS to and boot from a single portable VHD file (virtual disk) instead of hard drive?

  1. Yes (83 votes [96.51%])

    Percentage of vote: 96.51%

  2. No (3 votes [3.49%])

    Percentage of vote: 3.49%

Would you be interested to copy that VHD file to an empty USB Thumb or HD and boot from it on real PC?

  1. Yes (82 votes [97.62%])

    Percentage of vote: 97.62%

  2. No (2 votes [2.38%])

    Percentage of vote: 2.38%

Did you try to boot OS from VHD on real PC instead of Virtual Machine?

  1. Yes, I usually boot VHDs saved on an internal hard drive (36 votes [38.30%])

    Percentage of vote: 38.30%

  2. Yes, I usually boot VHDs saved on a USB drive or thumb (11 votes [11.70%])

    Percentage of vote: 11.70%

  3. Yes, I boot VHDs saved on drives of any type (13 votes [13.83%])

    Percentage of vote: 13.83%

  4. Not yet (34 votes [36.17%])

    Percentage of vote: 36.17%

Vote Guests cannot vote

#26 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 18 November 2011 - 10:51 PM

(the thing about having USB bootable medium with virtual pc and tools on it, is that one assumes it includes the relevant windows APIs to use those tools from your own programs... but this remains to be seen).

#27 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 18 November 2011 - 11:25 PM

MS Virtual PC doesn't fully support native boot VHDs - Hyper-V does. :)

Didn't catch sense of your idea of switching to USB / VPC from a tool to create & manipulate native boot VHDs (which is better to test from an internal drive). :dubbio:

Some usability ideas & Win 7 native boot VHD goals:

Native VHD Support in Windows 7

#28 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 19 November 2011 - 03:28 PM

MS Virtual PC doesn't fully support native boot VHDs - Hyper-V does.


Speaking of VHD support, this is the error code I get when trying to boot from a differenced VHD file, created as per my batch file (ergo, as per your instructions). This is the VHD I'm basing on the sysprepped Win7 VHD (which works fine).


0xC03A000B: The system does not support this version of the virtual hard disk. The block size is invalid.

English translation: The system does not support this version of the virtual hard disk. The block size is invalid.


Didn't catch sense of your idea of switching to USB / VPC from a tool to create & manipulate native boot VHDs (which is better to test from an internal drive). ../public/style_emoticons/default/dubbio.gif


I actually installed MOA241, and it's exactly what I wanted. To quote the author:

The MOA project started in 2003 as a plugin for Bart Lagerwijs PEbuilder. This plugin allowed to run VMware Workstation 4.5.2 from a Windows based LiveCD


Roll along 2011, and what you have is a true universal bootable USB/DVD with Windows 2003 x32 (SMP) running from a RAM disk, with an optional collection of various VHD and VMDK applications. The test ISO i made was about 350mb - with no VM apps installed, but a big set of drivers.

It will do dotnet with some tweaking, allowing stuff like Visual BCD Editor to be added, and of course it has no problem running the 32bit version of BCDEDIT from Win7.

And that means I can code C# applications that can be deployed from a live boot environment :)

Posted Image

Checked out that link, there are just so many M$ links to VHD stuff these days it's hard not to get lost. But it is good that we actually "going with the flow" rather than trying to hack something in to the operating system that isn't meant to be there. If Microsoft could just organise all their VHD information into a centralized location, then I wouldn't have ended up here to get Windows 7 too boot of a USB disk. It's really quite absurd, since I've later found Microsoft has complete video tutorials on this exact subject... but I only found them because I was using the right keywords in google. Keywords that someone who had never actually deployed a VHD to boot natively wouldn't even know.

#29 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 19 November 2011 - 03:36 PM

Sorry to note that Diff VHDs created from a detached read only Base VHD file in Disk Management or Diskpart in Win Server 2008R2 work quite well here without giving any errors. :dubbio:

Once you start using MS Tutorials or any Blogs info on VHDs and trying to play with VHDs, you quickly realize how incomplete these Tuts are. Try for example to resize in VHD Resizer a VHD created with Disk2VHD. :) That prompted me to write several Tuts here to accumulate useful info scattered in small pieces all over the web or gained from experience.

#30 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 20 November 2011 - 07:06 PM

So very true. But your work has made an impact... I think the crucial difference with your Bare Metal tutorial, is that you included "Boot from USB", which is simply "not the done thing" in a Microsoft tutorial.

I'm presently reading http://www.microsoft...&displaylang=en which is quite detailed, but in a good way. 40 pages worth. Has this gem in a native boot example:

imagex /apply ”C:SourcesWindows 7 EnterpriseSourcesinstall.wim” 1 v:

Maybe I just never noticed that in other tutorials... but it beats the heck out of having to clone disks.

BTW I'd don't know if you've ever heard of the very nerdy challenge to find google search terms that will return exactly 2 results, but I found one yesterday.

http://www.google.co...ot differencing


  • COM Error Codes (VOLMGR, BCD, VHD, SDIAG)


    msdn.microsoft.com/en-us/library/.../dd542650(v=vs.85).aspx 8 Sep 2011 – COM Error Codes (VOLMGR, BCD, VHD, SDIAG) .... The boot disk experienced failures. ... ERROR_VHD_INVALID_BLOCK_SIZE; 0xC03A000B ... in the identifiers of the parent virtual hard disk and differencing disk. ...


  • Native Boot VHD - reboot.pro


    reboot.pro › GroupsWindows ExtremeWindows 7
    10 posts - 4 authors - Last post: 23 Apr 2010 A very poorly documented feature of a native-boot vhd installation is the ability to create a 'differencing' disk. Creating a differencing disk and ...

(Well I thought it was cool).

Some bad news in my MOA bootable 2003 mission - DISKPART won't play... closer inspection shows there are 3 kernel side .sys files that simply aren't there. I think I will actually paste the M$ diagram here, since I'll probably never be able to find it again, and it could be useful.

Posted Image

#31 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 20 November 2011 - 07:12 PM

Sorry to note that Diff VHDs created from a detached read only Base VHD file in Disk Management


a) I've never understood the meaning of "read only VHD". Are you referring to: ATTRIB +R BASE.VHD, or is there some secret VHD flag I can't find
B) diskmgmt.msc can created differencing VHD's? Maybe in 2008 R2, but I sure didn't notice that option in W7.

#32 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 20 November 2011 - 07:23 PM

Some words tend to have a separate meaning: like "Diskpart" or VHD "file" (as opposed to attached VHD disk). Especially the "detached" Base one. :suda:

I think the format issue was expected, since MS keeps playing with VHD format and NTFS as well, and since you're into native boot Win7 Diffs, it makes sense to abandon the 2003 mission altogether, especially keeping in mind, how many people are eagily waiting now for your new VHD Manipulator GUI. :)

#33 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 20 November 2011 - 08:25 PM

To configure booting to a differencing VHD



1. To create differencing VHDs that have a parent/child relationship with the VHDs you created previously, type:



diskpart


create vdisk file="D:W2K8R2_Diff0.vhd" parent="D:W2K8R2.vhd"

exit



2. To boot to the differencing VHDs, you need to update the BCD store to reflect these intended changes. To do this, type the following commands, and use the GUIDs for the Windows 7 VHD boot entry and the Windows Server 2008 R2 VHD boot entry that you created in Steps 8 and 9. You can run the bcdedit /enum all /v command to view the appropriate GUIDs.




BCDEdit -store c:BootBCD /set {24761cb1-3f82-11de-8235-0003ffa37a4a} device VHD=[D:]W2K8R2_Diff0.vhd


BCDEdit -store c:BootBCD /set {24761cb1-3f82-11de-8235-0003ffa37a4a} osdevice VHD=[D:]W2K8R2_Diff0.vhd



This concludes the steps that are required for this advanced deployment scenario.

Edited by sfinktah, 20 November 2011 - 08:27 PM.


#34 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 20 November 2011 - 08:31 PM

The above was a quote from afore mentioned .doc file. Certainly simplifies the process, making it even hard to understand why it won't work for me.

I think the only thing left is for me to try it from a WinRe/WinPe session rather than another Windows 7 session.

So what is this tool I'm writing actually going to do? I haven't delved deeply into VHD, but I have the API and the technical specs in tabs at the moment... AFAIK you can make em, you can compact em, you can shrink em, merge em, difference them, copy them... am I missing anything?

Surely there is a tool for this already... it's just too obviously something that needs to exist.

These are the exposed API functions that are available in Windows 7 to manipulate VHDs. (i.e., what I can make a program do):
Topic Description
AttachVirtualDisk
Attaches a virtual hard disk (VHD) or CD or DVD image file (ISO) by locating an appropriate VHD provider to accomplish the attachment.
BreakMirrorVirtualDisk
Breaks a previously initiated mirror operation and sets the mirror to be the active virtual disk.
CompactVirtualDisk
Reduces the size of a virtual hard disk (VHD) backing store file.
CreateVirtualDisk
Creates a virtual hard disk (VHD) image file, either using default parameters or using an existing virtual disk or physical disk.
DetachVirtualDisk
Detaches a virtual hard disk (VHD) or CD or DVD image file (ISO) by locating an appropriate virtual disk provider to accomplish the operation.
ExpandVirtualDisk
Increases the size of a fixed or dynamically expandable virtual hard disk (VHD).
GetStorageDependencyInformation
Returns the relationships between virtual hard disks (VHDs) or CD or DVD image file (ISO) or the volumes contained within those disks and their parent disk or volume.
GetVirtualDiskInformation
Retrieves information about a VHD.
GetVirtualDiskOperationProgress
Checks the progress of an asynchronous virtual hard disk (VHD) operation.
GetVirtualDiskPhysicalPath
Retrieves the path to the physical device object that contains a virtual hard disk (VHD) or CD or DVD image file (ISO).
MergeVirtualDisk
Merges a child virtual hard disk (VHD) in a differencing chain with one or more parent virtual disks in the chain.
MirrorVirtualDisk
Initiates a mirror operation for a virtual disk.
OpenVirtualDisk
Opens a virtual hard disk (VHD) or CD or DVD image file (ISO) for use.
SetVirtualDiskInformation
Sets information about a virtual hard disk (VHD).


If your requirements fit inside that, it's not difficult to make a quick app.

Edited by sfinktah, 20 November 2011 - 08:36 PM.


#35 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 20 November 2011 - 08:54 PM

Don't forget to explicitly detach all parents' chain before creating a child VHD.

When we see the new VHD Manipulator Alpha, we'll go from there. :) Regarding GUI theme & appearance, something along EasyBCD GUI looks simple, intuitive and attractive.

I think, especially tricky parts are creating chained VHDs and resizing them (verifications wise) - to begin with, there is a need to understand, how VHD Resizer determines which VHD can be resized or converted. The resizing feature is quite important, since initially one often creates a VHD "in the dark".

What I'd suggest is to backup one partition of a multiboot drive to VHD with Disk2VHD, and try shrinking that VHD (its a whole partitioned drive with one partition copied and others empty), and analyzing how it goes. Lets not forget, resizing a VHD can affect its OS ability to boot in some scenarios, so it may require BCD update.

#36 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 20 November 2011 - 11:57 PM

Hmmm.... well the VHD I actually made and got working, was pretty much how you described.

100 mb Windows Boot
32 gb Windows System + Crysis II
64 gb store for "images" (.vhd and other backups i made).

But when I used Paragon to make the VHD, I just told it not to copy the images partition, and the resultant VHD was about 22gb.

Actually, I used Paragon to make it into a VMDK, then starwind to turn that into a VHD. So I'm pretty much in the dark about it's situation... I also cleared up a lot of space on it, and would like to shrink it. So lets play with that.

#37 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 12:03 AM

Posted Image


So it's just going to copy it...

#38 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 12:08 AM

"VhdExpand only supports Fixed and Dynamic Vhd Files"

A.K.A. it won't resize a differencing VHD. Which makes perfect sense to me, since I am a long time user of VMware, and I know that you can only resize a disk once you have removed or merged all the snapshots.

If you did shrink a parent VHD, then any VHDs that were based on it wouldn't work anymore.

Am I missing something?

#39 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 12:13 AM

Posted Image

This is my VHD (Disk 2)... just for the heck of it, I'm shrinking the partition to see what happens.

Edited by sfinktah, 21 November 2011 - 12:14 AM.


#40 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 12:51 AM

Posted Image

#41 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 01:23 AM

Sorry, just read the documentation on DISK2VHD..

It will create one VHD for each disk on which selected volumes reside. It preserves the partitioning information of the disk, but only copies the data contents for volumes on the disk that are selected. This enables you to capture just system volumes and exclude data volumes, for example.


I see what you mean about the empty partition... not an issue with Paragon, but clearly an issue here. However, the point of the exercise still eludes me. VHD Resizer works by copying the old VHD to a new VHD. That's just what it does.

Unfortunately it either doesn't work on differential VHDs, or my particular VHD is in some way broken.

If you're telling me that sometimes it does allow you to use a differential VHD as a source image, then you have intrigued me.

Otherwise, I assume you either have to merge your VHDs, or in my case (pictured about) where the I resized the partition in the child vhd, I would run disk2vhd over the attached vhd (or mount it with imdisk).

It is indeed rather poor than VHD Resizer doesn't appear to handle a more complex VHD... but if it did, the only result you could expect would be a single merged (and resized) VHD anyway.

#42 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 21 November 2011 - 01:44 AM

I didn't mention Diff VHDs when talking about resizing. But even with fixed Base VHDs, lets not forget that after resizing you still want to boot from it - its not always possible however, just try yourself. :)

BUT, lets stay on course for your alpha without much resizing, and see what happens. :good:

#43 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 06:22 AM

I didn't mention Diff VHDs when talking about resizing. But even with fixed Base VHDs, lets not forget that after resizing you still want to boot it - its not always possible however, just try yourself. :)

BUT, lets stay on course for your alpha without much resizing, and see what happen. :good:


I think, especially tricky parts are creating chained VHDs and resizing them (verifications wise) - to begin with, there is a need to understand, how VHD Resizer determines which VHD can be resized or converted. The resizing feature is quite important, since initially one often creates a VHD "in the dark".


I think we need to clarify whether we are going to include Expandable VHDs in this tool. I would tend to say "no", and simplify our options. Your base system should really be a Fixed VHD anyway, and I'm assuming that most cloning procedures would create fixed VHDs.

What do you think?

#44 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 07:38 AM

Speaking of volumes that won't boot, I resized my 20GB Crysis II VHD to a 10GB VHD... I had to use Acronis Disk Director to reduce the partition size to 10GB, and then I used VHD Resizer to copy it to a new 10GB VHD. (That part could have been done with "diskpart create vdisk ... maximum=10000 source=.... ).

Unsurprisingly, the VHD doesn't boot. 0xc0000225. (STATUS_NOT_FOUND).


A quick google shows that this is error is commonly caused by people resizing their (real) windows drives with linux based tools, and end up changing the GUID of their windows volume. In all cases I read, the answer was to use Windows Recovery.

I would suspect this would be one of the more common errors one would get, and finding a solution would be part of what this alpha application would do.

I've certainly never had any luck with Windows Recovery on a VHD before, but Visual BCD Edit quite impressive. It will automatically create missing VHD osloader entries if you ask it nicely.

Posted Image
Posted Image

And our new entry works. Which raises a curious point, because the new entry is identical to the previous one. Yet, in some way which isn't visible in Visual or regular BCDEDIT, they are different. One boots, one says 0xc0000225. (STATUS_NOT_FOUND). I've gone back and double checked both options.

Posted Image


Unless your sharp eyes can see a difference that I can't...

#45 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 21 November 2011 - 09:48 AM

Unless your sharp eyes can see a difference that I can't...



I wouldn't define my eyes as "sharp" but the identifier (or GUID) has changed.

:cheers:
Wonko

#46 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 09:55 AM

I wouldn't define my eyes as "sharp" but the identifier (or GUID) has changed.


That's because, just like you, it's Globally Unique.


-----------[i'm pretending this is my sig]-----------------------------------------------------------------------------------------------------------------------------------------
Posted Image

#47 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 10:02 AM

Adobe Photoshop CS 5 to the rescue. The best $1,500 I never spent.

Posted Image

(I overlayed the two)

------------------------------------------------------------------------------------------------------------- my pretend sig again --------------------------------------------------------------------------------------------------

Posted Image

Edited by sfinktah, 21 November 2011 - 10:03 AM.


#48 sfinktah

sfinktah

    Frequent Member

  • Advanced user
  • 217 posts
  • Location:Der Äther
  • Interests:/(C(++|#)|P(HP|XE)|(OS|Linu)X|8051)/
  •  
    Australia

Posted 21 November 2011 - 10:37 AM

Posted Image

... and that's what you get for installing to expandable VHDs without enough free disk space to expand the VHD.

Edited by sfinktah, 21 November 2011 - 11:11 AM.


#49 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 21 November 2011 - 01:02 PM

I remember reading somewhere that when system volume size is changed in a hard disk IMG file, Win can't boot any longer from that image until adjusted. Not sure why, but may be someone working with hard disk IMG files can explain. That isn't generally true about system volumes on physical drives. But after resizing a VHD file the same thing often happens, even if resizing its volume in Disk Management and then shrinking the file in VHD Resizer - the cause needs to be clarified too.

As to including expandable VHDs - the tool should allow to do as a minimum everything Disk Management Console can do with VHDs and more, and that includes of course working with dynamic and (guess what :)) differencing VHDs. If resizing is limited to making a smaller or larger VHD file copy after resizing its underlying partition, it should be no problem to include as well.

Of course, a physical drive where VHD is saved should have enough free space to hold a dynamic VHD when maxed out or booted from. Dynamic VHDs are quite attractive, when carrying several different OSs in VHDs on an external small drive or USB Thumb - because only one OS can boot at a time, so total space required is much less then sum of maxed dynamics. The physical drive should also have extra space for redirected Paging files.

#50 cdob

cdob

    Gold Member

  • Expert
  • 1469 posts

Posted 21 November 2011 - 05:00 PM

Which raises a curious point, because the new entry is identical to the previous one.

Bcedit output may be similar. But bcdedit dosn't list raw data.
There is no drive letter stored in \boot\bcd.
There is a binary data relating disk signature and partition layout stored.

\boot\bcd is a registry hive. Load offline file and compare raw data.

Compare: Fixing Disk Signature Collisions
http://blogs.technet...08/3463572.aspx





Also tagged with one or more of these keywords: vhd, bare metal, boot, win 7, grub4dos

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users