Imagex fills Windows 7 to vhd, differential vhd restoration protection, bcdedit creates XP & Windows 7 multi-system boot

Source: Internet
Author: User

Windows7/windows2008 R2 differential vhd restoration protection bcdedit

[The actual operation section above this article is original. For details, contact. The subsequent materials are sent to the network without verification .]

This article introduces
Use imagex to add Windows 7 (same operation for Windows Server 2008 R2) to a vhd file;
Use bcdedit.exe to start the computer from the vhd file;
Create a boot system that coexist with XP;
Create a differential vhd (implements restoration and backup functions similar to the ghost/recovery card)

[BTW] differential vhd will occupy a small amount of hard disk space, related information and benefits, disadvantages, please google.

The required tools except imagex.exe in the ms aik [click here to download] All other installation discs from Windows 7.

Imagex.exe download:

You need to use the Windows 7 boot disc, or use the ultraiso tool to fill the Windows 7 ISO file to the USB flash disk and start the computer from the USB flash disk.
[BTW] to use ultraiso 9.3 or a later version, select (write to hard disk image) in the (BOOT disc) menu, and then select your U disk drive.
Google can solve problems encountered in specific operations.

This section describes how to complete the entire operation by installing the Windows 7 startup u imagex.exe + Windows XP installation file on a computer.
If you have installed XP, go to step 1.

1. partition, install XP according to the normal situation. (Suppose you have installed it on the C drive .)

2. Install Windows 7 to d
[BTW] (you do not need to occupy the entire d partition, you do not need to format it, but make sure you have enough space .)
For more information about disk space and hardware requirements of Windows 7, Google.
You can also select another disk (it is recommended to place it on the NTFS partition, otherwise there will be problems when creating the vhd file,
If you are not using the NTFS format, you can use the convert command for quick conversion .)

Use a USB flash drive to start the computer. When displayed, [select the Windows 7 installation language interface], stop and press SHIFT + F10 to bring up the command line interface.
Figure 1 startup Interface]



A. Type diskpart to create the vhd file of the master disk.
(1) List volume (display volume, find your disk Information)
(2) create vdisk file = "D: \ w7b. vhd" Maximum = 15000 type = Expandable
(Create a primary vhd file on disk D and create a dynamic disk. Maximum has to calculate the maximum capacity, because a differential vhd is created later, differential vhd occupies the maximum capacity defined in the parent vhd file)
(3) Select vdisk file = "D: \ w7b. vhd"
(4) Attach vdisk)
(5) create partition primary (create primary partition)
(6) Assign letter = L (assign drive letter L and load it. Here l is only for temporary use .)
(7) format FS = NTFS quick label = vhd (fast format to NTFS and set the volume label to vhd)
(8) Exit (exit the diskpart tool)

B. Fill Windows 7 in the vhd just created.
Go to the imagex.execontents directory, and place imagex.exe in the boot USB flash drive and directory.

(1) imagex.exe/info e: \ sources \ install. Wim
E: \ sources \ install. Wim is the path of the Windows 7 installation CD. [Here is a USB flash drive]
(Use the imagex software on the USB flash disk to view the version contained in the Windows 7 installation disc. Remember the image Index = "N" version. Here, the ultimate version is 5)

(2)imagex.exe/apply E: \ sources \ install. Wim 5 L :\
(Decompress Windows 7 Ultimate to the mount point l disk of the virtual disk with imagex software on the USB flash disk-The drive letter set above .)

At this point, the preparation of the master disk is complete, and the startup information will be added to the system below to start windows7.

3. Add the startup information and set the XP startup information.

(1) bcdboot L: \ windows/s
(Write the boot information of Windows 7 just filled in to the primary partition. Disk L is the disk that just filled Windows 7 .)
(2) (update the master startup on the system partition)CodeSwitch from ntldr to bootmgr)
CD boot
Bootsect.exe/nt60 sys
(3) restore the XP startup Item
Bcdedit/create {ntldr}/D "Windows XP"
Bcdedit/set {ntldr} device partition = C: (select the disk of the XP system)
Bcdedit/set {ntldr} path \ ntldr
Bcdedit/displayorder {ntldr}-addlast
Bcdedit/set {ntldr} description "Windows XP"
Bcdedit (check whether it has been added successfully)

Now you have a dual system with XP and Windows 7. Windows 7 exists in the w7b. vhd file.
You can start Windows 7 and install some drivers and common software.
The following describes how to create a differential vhd to restore a video system.

4. Create a differential vhd to restore a video system.

Same as before. Use a USB flash drive to start the computer. When it appears, select the Windows 7 installation language interface and press SHIFT + F10 to bring up the command line interface.
(1) diskpart (Open diskpart)
(2) List volume (display the list of loaded volumes)
(3) create vdisk file = "D: \ w7d1. vhd" parent = "D: \ w7b. vhd" (create a differential vhd and set the primary vhd to the one just created)
(4) Exit (exit diskpart)
(5) Copy D: \ w7d1. vhd D: \ w7d1. vhd. Bak (Backup differential vhd file, not required)

5. Add boot information to the system for differential vhd.

(1) bcdedit
List all startup items, find the items of the parent disk you just added, and find its identity ID
Assume 611fd78f-03d4-4d94-81ba-30db9600cda9
(2) bcdedit/copy {611fd78f-03d4-4d94-81ba-30db9600cda9}/D "Windows7-2"
Copy the project of the master disk and modify it to the created differential vhd information.
After successful execution, a Sid similar to {38b5682a-4ca0-49d7-83a8-87f75ce85127} is returned, which will be used below.
(3) bcdedit/set {Sid} description "Windows7-2"
(4) bcdedit/set {Sid} device vhd = [D:] "\ w7d1. vhd"
(5) bcdedit/set {Sid} osdevice vhd = [D:] "\ w7d1. vhd"
(6) bcdedit/Set

Here you already have 3 boot items:. XP, Windows 7 (master disk), Windows7-2 (differential disk .)
The entire process is basically over.

If you already have XP, or you just want to install Windows 7 into vhd without using a differential hard disk, you can refer to the entire process and skip some steps.

Below are some supplements.
1. I changed the master disk. Can the sub-system of differential vhd be started?
According to many documents, the change of the master disk will make the sub-disk based on this disk unusable.
However, in actual use, it is found that if I start to the master disk and update a software, the sub-disk can still be started, but the changes to the master disk are not reflected in the sub-disk.
If you need to change the master disk to the sub-disk, you can perform the steps in Step 4 again. If the location and name of the created differential vhd are not changed, you don't need to use bcdedit to complete the startup Item.
If you change the name, you need it.
Note: If you change the size of the master disk, the sub-disk cannot be used any more. For example, if the disk space is insufficient
If the expand vdisk command is used to expand the size of the master disk, the sub-disk must be created again.

2. How to calculate the size of the sub-disk and how to expand the space?
The available size of the sub-disk = the available size of the master disk. The size of the sub-vhd cannot be set separately.
Select the file of the master disk in diskpart, and then use the expand vdisk command to expand the size of the master disk. The sub-disk must be created again.

3. I made some changes on the sub-disk. I need to merge the vhd to the master disk.
In diskpart, select the sub-disk file first, and then merge the merge vdisk depth = 1 command.

4. The actual vhd file size and other issues.
In Windows XP, you can see
The size of the vhd file is the actual size. For example, if a master disk with a maximum capacity of 15 GB is created before, but 5 GB is actually used, it is 5 GB.
The difference vhd is also the actual size, not the capacity set previously.
Start the Windows 7 master disk.
The difference vhd is also the actual size and will not be the previously set capacity. However, the size of the master vhd file is displayed as the maximum size of the master disk.
Start the sub-disk in Windows 7.
The size of the master disk vhd is also the actual size. It is not the size set previously. However, the size of the vhd file on the slave disk is displayed as the maximum size of the master disk.

5. Simple Restoration
Delete the sub-vhd file and execute the steps in Step 4 again. Refer to Supplement 1.
You can also make a bat script, which is a new sub-vhd every time you start the system, to achieve each restoration. I personally don't think it is necessary.


×××××××××××× The split line of the original content ×××××××××××××××××××××××××××


The following are some related questions. (Network or related documents. It is not original and has not been tested .)

1 What are the necessary conditions for starting a vhd instance?
Vhd boot itself has little hardware requirements and can only run the system. However, for software, the system must be of the following versions,
Windows 7 Enterprise
Windows 7 Ultimate
Windows Server 2008 r2
XP and Vista cannot be used because of driver problems. The version of win7 must be on the Enterprise Edition. This policy is restricted. if the version is incorrect, a message indicating that it is not supported is displayed.

2. Is the system started from vhd running on a virtual machine? Or is it directly running on physical hardware?
Is running on physical hardware.
Guide in win7 and win2008 r2ProgramAnd the system itself contains the vhd file read/write (virtual) driver, and virtual vhd disk controller.
Do not be misled by this virtual drive. This refers to analog hardware, such as the most common virtual Optical Drive.
Therefore, you can access and start vhd files when you start your computer. You can also create, load, and uninstall vhd files in Windows 7.
But the behavior is somewhat different. These drivers are in the system kernel, and the system itself will know that it runs on a vhd file.
Therefore, virtual memory files are stored on physical disks of non-vhd disks and not written into the vhd.

3. Is there any performance loss?
There will be some losses, but very small can be ignored.
The main reason is that the file system read/write access requires an additional layer of vhd read/write driver resolution, which has some trace I/O performance overhead,
However, compared with virtualization, the performance is basically close to that of a real machine.
It is the test materials found on the Internet. There is a group of direct reads from the hard disk and reads/writes to vhd, and the performance difference is minimal.
Figure 2 vhd Performance]


4. Can I mount x64 and x86 systems?
Yes. As long as you have hardware support. Add the corresponding entries in the boot guide.

The following is a supplementary introduction to vhd.
I. What types of vhd files are available?
There are three types of vhd files. You can use hyper-V manager or Windows 7 to create these file types:
1. Fixed vhd. The size of the Virtual Disk allocated to the fixed vhd file is the size of the Virtual Disk specified during vhd creation. For example, if the size of the created virtual hard disk is 2 GB, the system will create a file of about 2 GB, some of which are used in the internal vhd structure. The size of a fixed vhd does not change as data is written to the virtual hard disk.

2. scalable or dynamic vhd. The size of a scalable or dynamic vhd file at any given time is the same as the actual data size written to the file. As more data is written, the file will also dynamically increase. For example, the size of files that support 2 GB virtual hard disks is about 2 MB in the host file system. As data is constantly written to the virtual hard disk, the file increases until the capacity limit of 2 GB is reached.

3. Differential vhd. Differential vhd is similar to dynamic vhd, but only contains the modified virtual disk blocks of the parent virtual disk. The differential vhd is linked to a specific parent vhd, which is called a sub-vhd. The parent vhd file is a read-only file. All modifications are made to the Child vhd. The vhd file type of the parent vhd can be any of the three vhd types, including another differential vhd. Multiple Sub-vhd files form a differential chain.

2. Why is it recommended to use fixed vhd files in production?
We recommend that you use fixed vhd files for production for the following reasons:
"Because vhd files do not need to be dynamically extended, I/O performance is the highest among the three vhd disk types. At the same time, if you write to a fixed vhd file, the basic host volume of the vhd file will not fail to use up all available disk space because the dynamic vhd requires expansion.

"Dynamic and differential vhd files depend on multiple data write operations and internal block allocation information, if you have not completed all I/O operations on the host volume and the vhd file on the physical disk and have not saved it on the physical disk, the information may become inconsistent. This situation may occur when the basic disk uses up all the storage space or the system suddenly loses power.

3. When can I use dynamic or extended vhd files?
Dynamic vhd is useful when using Windows images in the following non-production environments: low storage requirements, and more convenient to replace vhd files than the reliability of data access in vhd. For example, the test environment can store a lot of dynamic vhd files in network sharing to save space, without having to allocate a fixed vhd format, similar to the storage space required for unused parts of the image. Generally, the test environment can be easily rebuilt or the vhd image for testing can be regenerated. Copying a smaller dynamic vhd file from a shared network to a local disk is faster than transferring a fixed vhd file of the same size. If you can regenerate all the content of dynamic vhd from other resources and store key data in other volumes than dynamic vhd, you can consider using dynamic vhd in the production environment.

4. What happens when the parent vhd of the sub-level differential vhd is changed?
The Sub-Level Differential vhd contains the modified data blocks in the specific parent vhd. If the parent vhd is changed or replaced with another vhd file with the same file name, the block structure between the parent vhd and the Child vhd will no longer match, and the content of the Child vhd will be damaged.

5. Can the parent level of the differential vhd be located on a volume or remote shared with the child level?
For vhd boot on the local machine, the link between the Child-Level Differential vhd and the parent vhd file requires that the two files are located in the same volume. Even if the parent disk and the sub-disk reside on the same local disk, they cannot reside in different volumes. When attaching a vhd outside of the local vhd startup (such as image management operations), the parent level of the differential disk can be located in other volumes or even remote sharing.

6. What are the functions of "creating vhd" and "attaching vhd?
Disk management tools (diskpart command line tool and disk management console) support creation, attachment, and separation. "Create vhd" allows you to create a new. vhd file based on the type and size specified by the option. You can think of the newly created. vhd file as similar to the original disk. The "add vhd" operation requires that the storage system use vhd as the disk to connect to the system. After you perform the "Attach vhd" operation, you can use the disk management tool to create one or more disk partitions in vhd and format the NTFS file system in vhd. If you perform the "Attach vhd" operation and the vhd already has a disk partition and a file system volume, the system allocates a drive letter to the volume in the vhd and the volume is available, this is similar to what happens when you insert a USB disk drive into a USB connector. "APPEND vhd" is sometimes called "show vhd" because the file system in vhd is assigned a drive letter and displayed, and is available. (You may think of a vhd as a submarine that appears and can be seen .)

After the "Attach vhd" operation is performed, the system allocates drive letters to all volumes in the vhd and makes them visible in the global namespace. Whether the attached vhd volume can be seen is not limited to the current user context. All users can see the attached vhd, just like what file systems can be used to view physical disks 7 and vhd?

If you already have a. vhd file, you can save it in any fat, exfat, NTFS, or udfs volumes. However, you can only append the vhd that is located in the NTFS Volume. Attaching vhd on a non-NTFS Volume will fail.

When creating vhd, you can create one or more partitions in vhd and format these partitions using fat, exfat, or NTFS. Additional operations can make one or more volumes in vhd available.

8. Can I append a remote shared vhd to Windows 7?
Yes. You can append a vhd file shared by a remote SMB instance, and the vhd file will be displayed as a local disk. Other remote file systems, such as NFS or FTP, are not supported. The system assigns a drive letter to the volume that is included in the vhd and these volumes are accessible to all users in the local system, depending on the security permissions of the data in the vhd volume. Remote vhd append supports remote image management.

9. Can I use NTFS to compress or encrypt a vhd file?
Vhd files compressed with NTFS on host volumes cannot be attached as virtual hard disks. Vhd files encrypted with an encrypted file system (EFS) on host volumes cannot be attached as virtual hard disks. Compressed or encrypted vhd files on host volumes cannot be used for vhd local startup. However, if other support is provided, the volumes in the vhd can be compressed and encrypted.

10. Can bitlocker be used to encrypt the entire vhd?
The vhd file can be stored on a host volume protected by bitlocker, but the vhd file on the bitlocker Protection Volume cannot be used for local startup. Enabling bitlocker for volumes contained in vhd is not a supported configuration.

11. What are nested vhd and what are nested limitations?
Vhd is the file on the host volume. For example, the vhd file c: \ vhd \ examplefixed. vhd indicates a fixed vhd file located in the \ vhd directory of the C: volume. In examplefixed. vhd, you can create a partition, initialize the NTFS file system volume, and temporarily assign the drive letter M :. You can also create a new vhd file under M: \ vhd \ anestedfixed. vhd. The second vhd file is created on the file system volume in the first vhd file. This is nested vhd. Execute the "Attach vhd" operation on c: \ vhd \ examplefixed. vhd to make M: volume available. The "APPEND vhd" operation on M: \ vhd \ anestedfixed. vhd makes another volume (for example, "N:") available. A maximum of two layers of nested vhd can be attached. This means that you can append another vhd to another vhd. However, if a vhd is attached to another vhd instance, The vhd instance fails to be attached to the vhd instance.

12. Can I configure two attached vhd instances as dynamic disks?
A Dynamic Disk is a disk initialized for dynamic storage. It contains dynamic volumes, such as simple volumes, cross-zone volumes, with-zone volumes, mirror volumes, or raid-5 volumes. The attached vhd cannot be configured as a dynamic disk.
Same. Vhd can only be appended to users with volume management permissions (Only Administrators are granted by default), because attaching a disk is equivalent to bringing the disk or volume online.

The following are related materials:
Understanding virtual hard disks with native boot
Http:// (ws.10). aspx

Built-in support for vhd files in Windows 7

Start a computer from a vhd File

In-depth study of virtual hard disk (vhd) technology in Windows 7

Start the computer from the Virtual Disk File

Bcdboot command line options
Http:// (ws.10). aspx

Bcdedit command line options
Http:// (ws.10). aspx

Windows (r) 7 automatic installation kit for Windows (R) (AIK)
Http:// Familyid = 696dd665-9f76-4267-a811-39c26d3b3b34 & displaylang = ZH-CN

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.