Delen via


Servicing and Backing Up Virtual Hard Disks

Applies To: Windows 7, Windows Server 2008 R2

This topic explains how to service and back up virtual hard disks.

  • Servicing VHDs

  • Backing up VHDs

Servicing VHDs

You can service a VHD offline or online by using command-line tools such as Deployment Image Servicing and Management (DISM.exe). The following procedures show how to add drivers and Windows features to an online (attached) VHD that is assigned drive letter Z. For more information about DISM, watch the screencast at Windows 7 Walkthrough: Deployment Image Servicing and Management (https://go.microsoft.com/fwlink/?LinkId=155183).

To add drivers to a VHD that is attached

  1. To add a single driver to the VHD image, type:

    Dism /image:Z:\ /Add-Driver /driver:C:\drivers\OEM.INF
    

    Alternatively, to add multiple drivers to the VHD image, type:

    Dism /image:Z:\ /Add-Driver /driver:C:\drivers\OEM.INF /driver:c:\drivers\OEM1.inf /driver:c:\drivers\OEM2.inf
    
  2. To confirm that the drivers were added to the image, type the following command and view the output:

    Dism /image:Z:\ /Get-Drivers
    

    For more information, see Driver Servicing Command-Line Options (https://go.microsoft.com/fwlink/?LinkID=163464).

To enable server roles and Windows features in a VHD that is attached

  1. To list all the features in the VHD, type:

    Dism /image:Z:\ /Get-Features
    
  2. To display information about the state of a specific Windows role or feature (this example displays information about the DHCP Server role), type:

    Dism /image:Z:\ /Get-FeatureInfo /FeatureName:DHCPServer
    
  3. To enable a specific Windows role or feature, run the following command (this example installs the DHCP Server role):

    Dism /image:Z:\ /Enable-Feature /FeatureName:DHCPServer
    

For additional information, see Operating System Package Servicing Command-Line Options (https://go.microsoft.com/fwlink/?LinkID=163465).

Backing up VHDs

Windows Server Backup is a backup and recovery solution for computers running the Windows Server 2008 R2 operating system. You can use Windows Server Backup to back up VHD volumes with some restrictions. For general information, see Windows Server Backup Overview (https://go.microsoft.com/fwlink/?LinkId=155187).

You should plan your backup strategy carefully for computers with VHDs. This section uses the example shown in the following table. The Example.vhd file, which contains a Windows 7 image, is located on drive C (the host volume). After it has been attached, the file system volume inside Example.vhd is drive D (the virtual volume).

  Physical Hard Disk Virtual Hard Disk

Volume

Host volume: drive C

Virtual volume: drive D

File System

\Vhd\Example.vhd

\Windows

Important

Volume Shadow Copy Service (VSS) does not support creating a shadow copy of a virtual volume and the host volume in the same snapshot set. VSS does support creating snapshots of volumes on a VHD (in the example, this is drive D), if backup of the virtual volume is necessary.

  • Determine whether your backup software will support VHD backup. Your existing backup and restore software may not support backing up or restoring the volumes contained in attached VHDs. The storage configuration of physical volumes that host VHDs, and volumes that are available to the system by attached VHDs requires careful planning to correctly back up the data on these volumes.

  • Detach any attached VHDs before you back up data. Windows does not support backing up a host volume (for example, C:) and the attached VHD (virtual volume D:) in the same backup set. If Example.vhd is attached and your backup includes the host volume C: and virtual volume D:, Windows will fail to create the snapshot because this is not supported. Instead, you should detach Example.vhd before backing up drive C:, and then Windows will successfully back up the host volume and any other data on the host volume (including the VHD). After backup of C: is complete, you can reattach the virtual volume D:. To restore the virtual volume D:, you need to restore the host volume C:, which includes the Example.vhd file in the backup.

  • Do not store critical data on the same volume as (or within) a native-boot VHD. If the native boot VHD does not contain critical data, it is easy to replace the VHD from a master copy or create a new VHD without the need to backup the virtual volume. However, if you store critical data on the same volume that hosts the VHD used to boot the system, it will be difficult to create a backup of the data. Therefore, we recommend that you store critical data outside the virtual volume that contains the system image (the native boot VHD). We also recommend that you do not store critical data on the same physical volume as the VHDs that are used for native boot or VHDs that have been attached for a long time. You can store VHD files on the same volume as other data (such as a network share) and back up the entire volume as long as the VHDs are not attached.

  • Store the VSS storage space for a VHD on the same virtual volume. You can back up a virtual volume (that is, an attached VHD), as long as the snapshot does not include both the virtual and host volumes together. The VSS storage space contains the change information for a snapshot, and you can configure the snapshot to reside on a volume other than the source volume. However, the storage space for a virtual volume (a native boot VHD or an attached VHD) must reside on the same virtual volume. Furthermore, a virtual volume cannot be used as the target volume for the snapshot of another volume. The virtual volume can store only the shadow copies that are associated with its own snapshots.