Windows 7中从VHD文件启动计算机

[摘要]  Windows 7对VHD文件的内建支持,VHD文件的地位得到了提升:-) ,它可以被操作系统认为是一块物理的硬盘进行管理和读写。

Windows 7对VHD文件的内建支持,VHD文件的地位得到了提升:-) ,它可以被操作系统认为是一块物理的硬盘进行管理和读写。

我们知道,现在启动系统的方式多种多样,可以从光盘、硬盘、软盘、U盘、网络等等不同的渠道来完成。既然VHD可以被Windows 7认为是一块独立的物理硬盘,那么我们是否可以从VHD启动操作系统呢?

答案是肯定的。Windows 7的引导程序也同样包含了对VHD文件的读写驱动,因此在装有Windows 7引导程序(Boot Loader)的计算机上,可以通过配置BCDEdit的方式,把VHD上的操作系统加入到启动时显示的多系统选择菜单。

下面我们来看一下具体的步骤:

注意,我们不能在物理计算机上通过光盘把系统安装到VHD文件。首先我们需要一个已经安装了操作系统的VHD文件,这可以通过几种方式来完成:

1. 在Virtual PC或者Hyper-V中完成安装,并且运行sysprep,然后关机,这VHD文件可以被Windows 7的Boot Loader启动。

2. 使用ImageX工具,把之前备份的操作系统镜像文件(ImageX格式)恢复到VHD中。

Adding the VHD Entry in Boot Menu and then Boot from VHD

当成功的创建VHD文件并且在VHD系统之上部署了操作系统之后,我们需要使用Windows 7的BCDEdit工具来配置系统的多启动菜单:

C:>bcdedit /copy {current} /d "My New VHD Description"

Note: This will Return the GUID of the Loader Object that you will use to replace below

C:>bcdedit /set device vhd=[driveletter:]\

C:>bcdedit /set osdevice vhd=[driverletter:]\

Note: vhd=[driveletter:]\ is the new syntax supported for BCDEdit.exe to locate VHD File and Bootmgr will locate the partition containing the VHD File to boot from.

C:>bcdedit /set detecthal on

Note:

Following is the attached screenshot of the my machine. In this case I have Windows 7 as the default OS and I have added the VHD File in the Boot Entry.

Well just after that run the following command to test if your boot entry is successfully created using C:>bcdedit /v

Similarly, if you want to add multiple VHDs into Boot entry you can use the following lines to the command prompt

C:>bcdedit /copy {current} /d "New VHD Description"

C:>bcdedit /set device vhd=[driveletter:]\

C:>bcdedit /set osdevice vhd=[driverletter:]\

C:>bcdedit /set detecthal on

Note: detecthal is used to force windows to auto detect the Hardware Abstraction Layer.

If you want to delete any existing VHD entry from the Boot Menu you can always use the command C:>bcdedit /delete /cleanup This deletes the specified operating system entry from the store and removes the entry from the display order.

Well, we are ready to Boot from VHD. Once you restart the computer you will see additional entry in Boot Menu along with the default Windows 7 or Windows Server 7 OS.

Here is the screenshot from newly booted Windows Server 2008 R2 Beta from VHD. I have installed Desktop Experience Pack and enabled Aero Glass.

看到这里,大家不免有一些问题:从VHD启动之后的系统,到底是运行在虚拟机上?还是直接运行在物理硬件之上?从VHD启动,还需要哪些必备的条件?是否会有性能的损失?下面我来回答这些问题:

1. Windows 7的引导程序和Windows 7本身都包含了对VHD文件的读写驱动程序,因此我们可以在启动计算机的时候,访问VHD并且从其上启动;我们也可以在Windows 7中直接创建、加载和卸载VHD文件。这些都是VHD读写驱动的功劳,跟Virtual PC或者Hyper-V没有直接的关系。因此Windows 7不需要安装任何虚拟化软件。

2. 从VHD启动之后,计算机的操作系统直接访问硬件,不是以虚拟化的方式运行。

3. 这里面唯一的区别,就是对文件系统读写访问的时候,需要经过额外的一层VHD读写驱动的解析,这里面有一些微量的I/O性能开销,但是跟虚拟化的情况相比,性能基本上接近了真机。我查了一些测试资料,有一组直接读取硬盘和读写VHD的比较,性能差别微乎其微。如下图:

4. 因为对VHD的支持仅包含在Windows 7中,因此我们不能在Windows 7中创建VHD后通过光盘给VHD安装任何操作系统。




免责声明:

本站系本网编辑转载,会尽可能注明出处,但不排除无法注明来源的情况,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本网联系, 来信: liujun@soft6.com 我们将在收到邮件后第一时间删除内容!

[声明]本站文章版权归原作者所有,内容为作者个人观点,不代表本网站的观点和对其真实性负责,本站拥有对此声明的最终解释权。