Jump to content











Photo

VHD Differencing Disks and Native VHD Boot

vhd differencing disks native vhd boot

  • Please log in to reply
3 replies to this topic

#1 misty

misty

    Gold Member

  • Developer
  • 1066 posts
  •  
    United Kingdom

Posted 25 March 2012 - 10:17 PM

This post is intended to provide an overview of Differencing type Virtual Hard Disks (VHD's) - focusing in particular on their use in Native VHD Boot deployment (note - the terms Native VHD Boot, Native Boot VHD and Native Boot are often used interchangeably). The VHD format has been around for a while and many people will be more familiar with it as the default disk type used by (Microsoft's) Virtual PC. VHD's are also used in hypervisor based virtual systems. The following (from here) helps to differentiate Native VHD Boot from other VHD deployments -

What is a native VHD boot?....This means that a VHD can be used as the running operating system on designated hardware without a parent operating system, virtual machine, or hypervisor. Furthermore, if you use native boot, you have full access to all devices and file system volumes on the physical computer, including the volumes inside the VHD. In contrast, when Windows runs in a virtual machine, only one file system volume in the virtual disk (volume C:) is available to guest machines (unless you share another volume to the virtual machine).


Before proceeding it should be stated that only limited versions of Windows actually support Native VHD Boot. At the time of writing these include -
  • Windows 8 Consumer Preview
  • Windows 7 Enterprise
  • Windows 7 Ultimate
  • Windows Server 2008 R2
Types of Virtual Hard Disk

There are three different types of Virtual Hard Disks - fixed, expanding and differencing. A fixed disk is similar to a RAW disk image, but contains a header and footer. Fixed disks have a specified size which will not change when data is written to a mounted image - a 10 GB fixed disk will consequently always be 10 GB on the host file system, regardless of the amount of unused space within it. Fixed disks are recommended by Microsoft in production environments.

An expanding disk will dynamically increase in size as data is written to it, up to the maximum size limit specified when it was created. Unlike a fixed disk it will not contain any unused space and consequently takes up considerably less space on the host file system. Expanding disks are recommended by Microsoft for use in nonproduction (e.g. test) environments.



Differencing Type Virtual Hard Disks

Differencing disk are more complex than either expanding or fixed type VHDs. A differencing disk (sometimes referred to as a Child) is always linked to a Parent disk. This link is hard-coded into the differencing VHD - if the link is broken (e.g. the Parent disk is renamed or moved) then the differencing disk cannot be booted or mounted to retrieve data. The underlying Parent Disk can be a fixed or expanding type disk. Another differencing disk can also be used as Parent, creating a chain of differencing disks. When a differencing disk is created, its size is not specified as it will always have the same maximum size as the underlying Parent disk - or the base disk in a chain of differencing disks.

For details on creating a Parent disk refer to the Recommended Reading section below.

A differencing disk only contains changes made from the base (Parent) image - "it contains only the modified disk blocks of the associated parent VHD". In practice it's not dissimilar to using Microsoft's Enhanced Write Filter - with all write requests being redirected from the Parent to the differencing image. A differencing disk is always a dynamically expanding type file, even when its Parent is a fixed type disk.

Assuming a differencing disk has been created from a Parent disk containing a Windows Operating System - when the differencing disk is mounted offline (not booted) all of the files contained in the parent will be accessible. Any files that are injected into the mounted differencing disk will only be saved in the differencing disk - the underlying Parent image will remain unchanged. This includes offline registry edits.

These same principles apply when the differencing disk is used for Native Booting. Any changes that are made to the operating system when the differencing disk is booted (e.g. an application is installed) will only be saved in the differencing image - the Parent image remains unchanged.

Interestingly, when a differencing disk is mounted offline its size on the host file system remains unchanged. In a test I ran, the differencing image was 912MB before being mounted and remained 912MB after being mounted - until data was written to it. The same differencing disk, when booted, was shown as being expanded to it's maximum size on the host file system - 15GB for the file I used in these tests.



Creating DIfferencing Disks

To create a differencing disk, start DiskPart (the easiest method is to open a Run command box/window and type diskpart [ENTER])

In diskpart, use the following command syntax to create a differencing disk -
create vdisk file=PATH_TO_DIFFERENCING_IMAGE parent=PATH_TO_PARENT_IMAGE
E.g.
create vdisk file=C:\Differencing.vhd parent=C:\Parent.vhd

That's it. Well done!



WARNING

Please take note of the following (from Frequently Asked Questions: Virtual Hard Disks in Windows 7 and Windows Server 2008 R2) -

You should not modify the parent of a differencing VHD. If the parent VHD is changed or replaced by a different VHD (even if it has the same file name), the block structure between the parent and differencing VHD will no longer match and the differencing VHD will be corrupted.


To reiterate - DO NOT BOOT FROM, OR EDIT, THE PARENT DISK. If any changes are made to a Parent disk, then any differencing (child) disks are unlikely to boot.



Repairing a Link to a Parent Disk

See post number 2



Differencing Disk Limitations

Refer to the linked documents in the Recommended Reading section below for a more detailed list of Native VHD Boot limitations.

Boot files (including bootmgr and the BCD store) and the pagefile are not stored in the Virtual Hard Disk and must remain on the host file system - the VHD is therefore not completely self contained and if it is moved to a new system then new boot files will need to be created.

Hibernation is not supported, however sleep mode is.

Expanding and differencing type disks are expanded to their maximum size when booted - the host volume must therefore be large enough to contain the expanded disk.

According to Frequently Asked Questions: Virtual Hard Disks in Windows 7 and Windows Server 2008 R2 -

You must keep both files (the parent VHD and the differencing VHD) in the same directory on a local volume for native-boot scenarios. For native-boot VHDs, the parent VHD and the differencing disk cannot reside on different volumes, even if they reside on the same local disk. However, when you attach a differencing VHD that is not used for native boot (for example, if you plan to use it for image management), the parent VHD can be in different directories, and on a different volume or even on a remote share.

During my tests booting Windows 8 Consumer Preview from a differencing VHD I was able to boot a differencing disk whose Parent disk was in a different directory. It would not boot when the Parent disk was moved to another volume on the same physical disk - in fact the menu entry disappeared from the boot menu after the parent disk was moved.



Recommended Reading

Frequently Asked Questions: Virtual Hard Disks in Windows 7 and Windows Server 2008 R2 - Includes the following; What is a native VHD boot?, What are the different VHD file types?, Why are fixed VHDs recommended for production?, When is it appropriate to use dynamically expanding VHDs?, What does it mean to create, attach, and detach VHDs?, Are there any restrictions that I should be aware of when attaching VHDs?, What are the recommendations for using VHDs for native boot?, What is not supported for native boot when using VHDs?

Understanding Virtual Hard Disks with Native Boot - Includes detailed information on the following topics; What Is VHD with Native Boot?, Common Scenarios, Requirements, Benefits, Limitations, Recommendations, Types of Virtual Hard Disks, Technologies Related to VHDs with Native Boot

Native Boot VHD - Forum thread by diddy. Sadly a lot of information in this thread appears to have been lost in one of the board updates.

Create Native Boot VHDs - Forum thread by sambul61. Contains one method for creating a Native VHD Boot base image.

System & Differencing VHDs synch and update strategy - Post by sha0. Contains interesting suggestions on how he might use a chain of differencing images for a Native VHD Boot setup.

VHD Based Windows To Go - Post by me. Contains a walkthrough for creating a Native VHD Boot base image using a Windows 8 Consumer Preview installer. It might need adapting as it's focused on creating a VHD installation on a USB hard disk.

Regards,

Misty

#2 misty

misty

    Gold Member

  • Developer
  • 1066 posts
  •  
    United Kingdom

Posted 25 March 2012 - 10:18 PM

Repairing a Link to a Parent Disk

If its Parent disk has been renamed or moved then it will not be possible to boot or mount a differencing disk. When using Diskpart to attempt to mount (attach) a differencing disk with a broken link to its Parent, the following error was displayed -
DISKPART> select vdisk file=C:\differencing.vhd



DiskPart has encountered an error: The chain of virtual hard disks is broken. The system cannot locate the parent virtual hard disk for the differencing disk. See the System Event Log for more information.



There is no virtual disk selected.

It is possible to reconnect a differencing disk to its Parent using Virtual PC (tested using version 2004 on Windows XP, and version 2007 on Windows 7) or Virtual Server 2005 R2 SP1.



Download Links

Virtual PC 2007
Virtual PC 2004
Virtual Server 2005 R2 SP1



Virtual PC 2004/2007

To use Virtual PC to reconnect a differencing disk to its Parent

1 - Start Virtual PC

2 - Go to the File menu and select Virtual Disk Wizard

3 - This will open the Welcome to the Virtual Disk Wizard - Select Next

4 - Disk Options - Select Edit an existing disk and then select Next

5 - Virtual Disk to Edit - browse for the differencing VHD file to be edited

6 - This will open a new window (Select File) with the following message - "The parent virtual hard disk has been deleted or has been moved from its previous location. Please select the new location of the parent virtual hard disk." Select Change, browse to the Parent disk, then select Ok

7 - You might see an error warning at this stage with the following message displayed - "The virtual hard disk's parent appears to have been modified without using the differencing virtual virtual hard disk.

Modifying the parent virtual hard disk may result in data corruption.It is strongly recommended that you mark the parent virtual hard disk as read-only to prevent this in future. If you recently changed time zones on your host operating system, you can safely continue using this virtual hard disk."
. Ignore the message and select OK

8 - The Virtual Disk Information and Options window will be displayed. The differencing disk should have been reconnected to its Parent - select Cancel



Virtual Server 2005 R2 SP1

Assuming that Virtual Server 2005 R2 SP1 has been installed successfully (see below for instructions on installing in Windows 7/8) -

1 - Open the Virtual Server Administration Website

2 - In the left pane, select Virtual Disks > Inspect to open the Inspect Virtual Hard Disk options

3 - In the Fully qualified path to file: box, enter the filename (with path) to your differencing image, then click on the Inspect button.

4 - This will open Virtual Hard Disk Properties for the selected disk. In the Parent virtual hard disk(s) section a message similar to the following will be displayed - "The virtual hard disk file "\Device\HarddiskVolume#\path_to_my.vhd" is in use by another process. Click here to update it.". Click on this link.

5 - This will open Update Virtual Hard Disk Parent options. In the Parent Virtual Hard Disk Path filed, enter the full path to the Parent disk, then click on the Update Parent Path button.

6 - You should return to the Virtual Hard Disk Properties for the selected differencing disk - hopefully with the new Parent disk listed correctly in the Parent virtual hard disk(s) section. You can close the Virtual Server Administration Website.



Installing Virtual Server 2005 R2 SP1 on Windows 7/8

The following instructions are from an article by Ben Armstrong - Installing Virtual Server 2005 R2 SP1 on Windows 7

Virtual Server 2005 R2 SP1 is blocked due to compatibility issues with Windows 7 (and 8). It's possible to complete the installation by disabling the Program Compatibility Assistant and Application Compatibility Engine. A word of caution from the article I referenced earlier -

Before moving on I would like to quickly discuss exactly what the impact of these policy changes are:

1 - Disabling the Program Compatibility Assistant means that Windows will no longer tell you when you are about to run a program with known compatibility problems. It will just sit by quietly and let you try (and most likely fail).

2 - Disabling the Application Compatibility Engine means that Windows will no longer try to correct known compatibility issues. This means that there may be programs that were working before that start failing – because Windows is no longer fixing things up for them.

So the summary is that you should really only do this if you are running a limited set of applications and can confirm that they all can run with the application compatibility engine disabled.


1 - Open the Local Group Policy Editor (the easiest method is to open a Run command box/window and type gpedit.msc [ENTER])

2 - Select Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Application Compatibility

3 - Find the Turn off Application Compatibility Engine entry, double click on it, Select the Enabled button and then click on OK

4 - Find the Turn off Program Compatibility Assistant entry, double click on it, Select the Enabled button and then click on OK

5 - Restart the computer for these changes to take effect, then run the Virtual Server 2005 R2 SP1 installer

If anyone know of an easier method to reconnect differencing disks that does not requiring installing either of these programs then please let me know.

Regards,

Misty

#3 RPhippsy

RPhippsy
  • Members
  • 1 posts
  •  
    United Kingdom

Posted 03 November 2013 - 11:41 AM

I really should have read this before I tried to boot from the parent VHDX....

 

Is there any way at all to recover the files after the "chain of virtual hard disks is corrupted" error  (unfortunately from a Linux file system which complicates things on my Windows Server 2012) if I don't have a backup (which I don't - I stupidly assumed snapshots were) is it a lost cause?

 

Thanks, and sorry for posting on an old thread.

 

Rob



#4 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 03 November 2013 - 12:42 PM

RPhippsy,

the post just above yours actually explains methods to "repair" the "chain of virtual disks".

http://reboot.pro/to...-boot/?p=151254

 

 

Repairing a Link to a Parent Disk

....

It is possible to reconnect a differencing disk to its Parent using Virtual PC (tested using version 2004 on Windows XP, and version 2007 on Windows 7) or Virtual Server 2005 R2 SP1.

 

 

So, WHAT :w00t: is the problem?

Did you already try BOTH the two different methods to do that and failed with both? :dubbio:

Or are you having a different problem/issue/whatever?

 

 

:cheers:

Wonko







Also tagged with one or more of these keywords: vhd, differencing disks, native vhd boot

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users