循序渐进:将Windows 7 DVD或ISO转换为可引导的VHD虚拟机

I'm loving the Windows 7 "Boot to VHD" lifestyle. This isn't Virtual Machines, to be clear, and it's not Dual Booting. It's Boot to VHD.

喜欢Windows 7的“引导到VHD”生活方式。 显然,这不是虚拟机,也不是双重引导。 它启动到VHD

Let me break it down:

让我分解一下:

MethodProsCons
Dual BootingYour OS's always run at full speed.You can screw up your partition table. You have to partition which means disks of fixed size. Or you can have them all share the same disk, which is dangerous.
OS's aren't portable.
Virtual MachinesYour OS's are completely separate from each other and can't hurt one other. Your OS's are very portable. You get Undo support for your disks.Everything is virtualized, so you're taking a perf hit on pretty much everything. Often not a good solution for laptops.
Boot to VHDYour OS runs on the hardware directly, except your disk, which is virtualized and runs inside a single file. Estimated 3%-5% perf hit. Seriously. Also is awesome on a laptop if you have the HD space.None! But I'm biased! Neener neener!
Only works on internal drives or ESATA. No USB Drive support. No undo disk support.
方法 优点缺点
双启动您的操作系统始终全速运行。 您可以破坏分区表。 您必须进行分区,这意味着磁盘具有固定大小。 或者您可以让它们全部共享同一个磁盘,这很危险。
操作系统不可移植。
虚拟机 您的操作系统彼此完全分开,不会互相伤害。 您的操作系统非常便携。 您将获得对磁盘的撤消支持。 一切都是虚拟化的,因此您几乎对所有内容都感到不满意。 对于笔记本电脑而言,通常不是一个好的解决方案。
引导到VHD 您的操作系统直接在硬件上运行,磁盘除外,磁盘已虚拟化并在单个文件中运行。 估计有3%-5%的命中率。 说真的如果您有高清空间,在笔记本电脑上也很棒。 没有! 但是我有偏见! 内纳内纳!
仅适用于内置驱动器或ESATA。 不支持USB驱动器。 没有撤消磁盘支持。

Making a VHD is easy with Windows 7 since you can create and mount/attach VHDs in the standard tools. VHD as a disk format is built into the Operating System (although, strangely, you can't mount ISOs.).

使用Windows 7可以轻松制作VHD,因为您可以在标准工具中创建和安装/连接VHD。 VHD作为磁盘格式内置在操作系统中(尽管很奇怪,您无法挂载ISO。)。

You can create a blank VHD, set it up in your boot menu with BCDEdit (details and walkthrough here and a video demo here) and then just boot off your VHD. If you want to install your OS (Windows Server 2008 and Win 7 Enterprise or Ultimate are the only ones supported) then you just install away.

您可以创建一个空白的VHD,使用BCDEdit在启动菜单中对其进行设置(详细信息和此处的演练以及此处视频演示),然后直接启动VHD。 如果要安装操作系统(仅支持Windows Server 2008和Win 7 Enterprise或Ultimate),则只需安装即可。

However, this is STILL not convenient enough for me.

但是,这对我来说仍然不够方便。

I'm always trying crazy new Daily Builds of big stuff that takes a while to be installed. The step where I install an OS onto my VHD takes too long, so I'd like a prepared VHD that's already to be started for the first time, kind of like when you buy a machine from Dell or whoever and you get that nice "starting your computer, detecting drivers" action on first boot.

我一直在尝试疯狂的大型日常新版本,需要一段时间才能安装。 我在VHD上安装操作系统的步骤耗时太长,因此我希望已经准备好的VHD首次启动,就像您从Dell或任何人那里购买一台计算机而得到的那样好”启动计算机,并在首次启动时检测驱动程序”操作。

Well, there's a script over at the MSDN Code Gallery to help with this. It's the Windows Image to Virtual Hard Disk Converter (WIM2VHD).

好吧,MSDN代码库中有一个脚本可以帮助您解决此问题。 这是Windows映像到虚拟硬盘转换器(WIM2VHD)

From their description:

根据他们的描述:

The Windows(R) Image to Virtual Hard Disk (WIM2VHD) command-line tool allows you to create sysprepped VHD images from any Windows 7 installation source. VHDs created by WIM2VHD will boot directly to the Out Of Box Experience, ready for your first-use customizations. You can also automate the OOBE by supplying your own unattend.xml file, making the possibilities limitless. Fresh squeezed, organically grown, free-range VHDs - just like Mom used to make - that work with Virtual PC, Virtual Server, Microsoft Hyper-V, and Windows 7's new Native VHD-Boot functionality!

Windows(R)映像到虚拟硬盘(WIM2VHD)命令行工具使您可以从任何Windows 7安装源创建系统准备的VHD映像。 由WIM2VHD创建的VHD将直接引导至“开箱即用”体验,为您的首次使用自定义做好准备。 您还可以通过提供自己的unattend.xml文件来自动化OOBE,从而使可能性无限。 像妈妈以前制作的那样,新鲜榨汁,有机种植的自由放散VHD可以与Virtual PC,Virtual Server,Microsoft Hyper-V和Windows 7的新Native VHD-Boot功能一起使用!

I like this guy already.

已经喜欢这个家伙了

如何SysPrep您的Windows 7映像 (How to SysPrep your Windows 7 Image)

I copied my Windows 7 DVD to a folder on a drive with lots of space free. I probably didn't need to copy it over, but it likely made the process faster.

我将Windows 7 DVD复制到驱动器上具有大量可用空间的文件夹中。 我可能不需要复制它,但是它可能使过程更快。

Then I downloaded and installed the Windows® Automated Installation Kit (AIK) for Windows® 7. This file is a large ISO (1.5G) so be aware. It's meant for admins, not humans. I didn't want to burn the ISO to disk, so I used 7-Zip to open the ISO as an archive and extract it. (If you're not using 7-Zip, you're missing out on life, BTW)

然后,我下载并安装了Windows®7的Windows®自动安装工具包(AIK) 请注意,此文件是大型ISO(1.5G)。 它是针对管理员而非人类的。 我不想将ISO刻录到磁盘,因此我使用7-Zip打开ISO作为存档并将其解压缩。 (如果您使用的不是7-Zip,那您将失去生命,顺便说一句)

Now, go into C:\Program Files\Windows AIK\Tools and find ImageX.exe and copy it where you put the Windows Image to Virtual Hard Disk Converter (WIM2VHD) script.

现在,进入C:\ Program Files \ Windows AIK \ Tools,找到ImageX.exe并将其复制到将Windows Image放入虚拟硬盘转换器(WIM2VHD)脚本的位置。

Go read the Example Command Lines for Win2VHD, but since I had a Windows 7 Ultimate I ran this command-line. Note that d:\win7working is where I copied my DVD.

请阅读Win2VHD示例命令行,但是由于我有Windows 7 Ultimate,因此运行了此命令行。 请注意,d:\ win7working是我复制DVD的位置。

cscript wim2vhd.wsf /wim:d:\win7working\sources\install.wim /sku:ultimate

cscript wim2vhd.wsf /wim:d:\win7working\sources\install.wim / sku:ultimate

In this example, d:\win7working is the folder I copied the DVD to. Could be your DVD drive too, I suppose.

在此示例中,d:\ win7working是我将DVD复制到的文件夹。 我想也可能是您的DVD驱动器。

It chewed for a while, maybe seven minutes. You'll also here the "Device Plugged In" sound as the script automatically connects a VHD as a drive temporarily so don't panic:

它咀嚼了一会儿,也许是七分钟。 您还会在此处看到“设备已插入设备”的声音,因为脚本会自动将VHD临时连接为驱动器,所以不要惊慌:

D:\>cscript wim2vhd.wsf /wim:d:\win7working\sources\install.wim /sku:ultimate
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Windows(R) Image to Virtual Hard Disk (WIM2VHD) Converter
Copyright (C) Microsoft Corporation. All rights reserved.
Version 6.1.7100.2

Check for updates at http://code.msdn.microsoft.com/wim2vhd!

MACHINE INFO:
Build=7600
Platform=amd64fre
OS=Windows 7 Ultimate
ServicePack=
Version=6.1
BuildLab=win7_rtm
BuildDate=090713-1255
Language=en-US

INFO: Looking for IMAGEX.EXE...
INFO: Looking for BCDBOOT.EXE...
INFO: Session key is E765F413-44E9-4F9B-AEA5-DBC8A726F7A6
INFO: Inspecting the WIM...
INFO: Configuring and formatting the VHD...
INFO: Applying the WIM...
[ 100% ] Applying progress
INFO: Making the VHD bootable with BCDBoot...
INFO: Unmounting the VHD...
Summary: Errors: 0, Warnings: 0, Successes: 1
INFO: Done.

Magical. Now I've got a 5 gig VHD file that I can setup to boot from directly as described here. The first time I start up, it'll be 95% into the setup process and just ready to detect my hardware. It's a nice "OEM-like" VHD that I can use again and again.

神奇。 现在,我有一个5 gig VHD文件,可以将其设置为直接启动,如此处所述。 第一次启动时,它将进入设置过程的95%,并准备检测我的硬件。 这是一个不错的“类似于OEM的” VHD,我可以一次又一次地使用它。

Since I'm only using these VHDs temporarily (for a week or two for testing) I won't use an activation key and instead leave that field blank during setup. That'll buy me 30 days of testing if I need to, and I can easily start over by just starting over with my new fresh VHD.

由于我只是暂时使用这些VHD(一两个星期进行测试),因此我不会使用激活密钥,而是在设置过程中将该字段留空。 如果需要的话,那将为我提供30天的测试时间,并且只要重新开始新的VHD,就可以轻松地重新开始。

Enjoy! Now go tell Mike and his team that they're awesome. Go ahead. I'll wait here.

请享用! 现在去告诉迈克和他的团队他们很棒。 前进。 我在这里等

Related Links

相关链接

翻译自: https://www.hanselman.com/blog/stepbystep-turning-a-windows-7-dvd-or-iso-into-a-bootable-vhd-virtual-machine

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值