Go deep into Windows 7 Virtual Hard Disk (VHD) technology

  

Understanding VHD Formats

Most people initially come into contact with VHD format files. When using Virtual PC or Virtual Server, VHD is a virtual machine disk that exists as a file. Microsoft disclosed the full details of the VHD format file in 2005. The Virtual Hard Disk Image Format Specification can be downloaded from Microsoft's TechNet website. This shows that Microsoft not only needs to apply VHD in the field of virtual machines, but also hopes that VHD can become a new disk format and carrier to get more support in the industry.

Let's put aside the virtual machine and focus on the VHD file itself. The VHD is a virtual hard disk. Unlike the disks, heads and tracks of a traditional hard disk, the VHD hard disk carrier is a VHD file on the file system. If you carefully read the technical standards of VHD files, you will find that the standard defines a lot of hard drive specific terms such as Cylinder, Heads and Sectors to simulate I/O operations for hard disks. Since the VHD is a hard disk, it can be partitioned, formatted, read and written, just like a physical hard disk.

We can think that VHD is also a kind of hard disk. Just like 2.5-inch, 3.5-inch, SCSI, SATA, IDE and other hard drives of different specifications, VHD is a hard disk in one file.

Windows 7 supports VHD technology implementation

Before discussing the specific technical implementation, we first need to understand the operating system to manage disks and files. The operating system has two parts, a disk system and a file system, which handle I/O read and write commands (disk systems) on the hard disk, and manage partitions, data, and file formats (file systems) on the hard disk. A VHD is a disk that exists on top of a file. It is conceivable that its technical implementation must span both the disk system and the file system. If you are not very familiar with this part of the operating system, you can listen to the Windows storage technology series Webcast on the Microsoft website.

To put it simply, to read and write a VHD file as a hard disk, you must have the appropriate driver. In Virtual PC and Virtual Server, Microsoft added the VHD driver to the virtual machine, enabling the virtual machine to boot from the VHD and perform subsequent operations.

In Windows 7, Microsoft built the VHD driver into the operating system, which is also included in the Windows 7 bootloader. That is to say, we can directly access the contents of the VHD file when using Windows 7 (mapping the VHD hard disk to a drive letter, which will be described in detail later), or booting the VHD through the boot program of Windows 7. Another operating system on the disk. Understanding the working details of the VHD driver requires a lot of Windows underlying knowledge. The following figure is a relatively simple and abstract structure. It can be found that the VHD driver is closely integrated with the disk drive and file system.


Can't the picture be clear? Please click here to view the original image (larger image).

Dazzling VHD Applications

Since Windows 7 can read and write directly to VHD, let's take a look at how powerful this powerful feature can be.

First, we can create a VHD file with the command line tool Diskpart! (Yes, the command line tool, you may have thought of automated batch processing and batch deployment can use this technology, yes, the network management said: to the hard disk, so a lot of VHD was created …)

1: diskpart 2: create vdisk file=c:windows7.vhd maximum=25600 type=fixed 3: select vdisk file=c:windows7.vhd 4: attach vdisk 5: create partition primary 6: assign letter=r 7 : format quick label=vhd 8: exit The above command creates a fixed-size VHD file and partitions, assigns a drive letter and formats it in one go. Diskpart can also do a lot of things, please refer to this document for specific parameters. If you don't like the command line, Windows 7's disk management tool can do the same. Now let's take a look at several ways that VHD can be accessed directly in Windows 7:

Method 1: As shown on the right, the Foo.VHD file can contain more than one disk partition. These partitions can be mapped to Windows operations. In the system, you can assign a drive letter to it, or you can map to an NTFS directory.


Can't the picture be clear? Please click here to view the original image (larger image).

Method 2: As shown on the right, the VHD disk can contain VHD files. This VHD file can also be mapped to the operating system. The current version of Windows supports 2 levels of nested VHD. (I really can't think of any practical use, it is said that this feature may be removed in the official version, so as not to confuse users)



Copyright © Windows knowledge All Rights Reserved