我用 MediaCreationTool 创建了一个 Windows 10 1709(Fall Creators Update)的 ISO 镜像文件。这样下载的镜像文件和直接从 MSDN 下载的略有不同——最大的不同大概是系统镜像存放在名为
install.esd 而非
install.wim 的文件中。因为特殊需求,我需要把它安装到一块 USB 外置硬盘上,在我的 MacBook Pro 13’(2013 年末款)上使用它;又因为从朋友那借来了 Akitio Node 外置显卡盒子,无法使用 Windows To Go 安装(Windows To Go 无法安装显卡驱动),因此只能非常蛋疼地手工安装系统了。
在开始之前,请准备一台 Windows 10 设备,并打开一个具有管理员权限的 PowerShell 或命令提示符,所有操作将在其上完成。
本文遵循以下假设:
-
D: 是一个空闲的可用磁盘
- ISO 安装镜像已挂载到
J:
-
T: 至
X: 未被占用
提取 WIM
(如果你手上的 ISO 文件是 MSDN 版本,则不需要进行本步骤操作。一路使用你 ISO 镜像内的
\sources\install.wim 继续即可,不过要注意
dism 的
/index:N 参数。)
首先挂载 ISO 文件,找到
\sources\install.esd 文件,确定需要安装的系统版本的
Index (也可以在用 ISO 启动进入安装程序的系统版本选择步骤时看到,注意是从 1 开始数的):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
PS C:\> dism /get-wiminfo /wimfile:J:\sources\install.esd Deployment Image Servicing and Management tool Version: 10.0.16299.15 Details for image : j:\sources\install.esd Index : 1 Name : Windows 10 S Description : Windows 10 S Size : 15,748,508,043 bytes Index : 2 Name : Windows 10 S N Description : Windows 10 S N Size : 14,682,635,068 bytes Index : 3 Name : Windows 10 Home Description : Windows 10 Home Size : 15,567,580,753 bytes Index : 4 Name : Windows 10 Home N Description : Windows 10 Home N Size : 14,496,690,559 bytes Index : 5 Name : Windows 10 Home Single Language Description : Windows 10 Home Single Language Size : 15,569,063,438 bytes Index : 6 Name : Windows 10 Education Description : Windows 10 Education Size : 15,746,024,004 bytes Index : 7 Name : Windows 10 Education N Description : Windows 10 Education N Size : 14,680,122,009 bytes Index : 8 Name : Windows 10 Pro Description : Windows 10 Pro Size : 15,746,775,851 bytes Index : 9 Name : Windows 10 Pro N Description : Windows 10 Pro N Size : 14,680,828,085 bytes The operation completed successfully. |
然后把特定
Index 的系统文件单独提取到一个
wim 镜像中:
|
PS C:\> dism /export-image /sourceimagefile:j:\sources\install.esd /sourceindex:8 /destinationimagefile:D:\install.wim /compress:max /checkintegrity Deployment Image Servicing and Management tool Version: 10.0.16299.15 Exporting image [==========================100.0%==========================] The operation completed successfully. |
格式化硬盘
启动一个管理员权限的命令提示符或 PowerShell,打开 DiskPart 程序,选中目标硬盘:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
PS C:\> diskpart Microsoft DiskPart version 10.0.16299.15 Copyright (C) Microsoft Corporation. On computer: [redacted] DISKPART> list disk Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 3539 GB 0 B * Disk 1 Online 465 GB 0 B * Disk 2 Online 465 GB 0 B * Disk 3 Online 953 GB 0 B * Disk 4 Online 238 GB 0 B * DISKPART> select disk 4 Disk 4 is now the selected disk. |
分区(以下命令均在 DiskPart 内部,选中目标硬盘之后执行;请务必检查选中了哪块硬盘,因为以下操作会抹去该硬盘现有的所有数据)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
clean convert gpt create partition primary size=512 format quick fs=ntfs label="Windows RE tools" set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" assign letter="T" create partition efi size=260 format quick fs=fat32 label="System" assign letter="U" create partition msr size=128 create partition primary shrink minimum=15000 format quick fs=ntfs label="Windows" assign letter="W" create partition primary format quick fs=ntfs label="Recovery image" set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" gpt attributes=0x8000000000000001 assign letter="X" exit |
分区结束后,该硬盘将有如下分区表(以我 240G 的硬盘为例;如果硬盘实际大小不同,Windows 系统分区大小将会自动改变,其余分区不变):
序号 |
类型 |
大小 |
偏移 |
卷标 |
1 |
保留 |
128MB |
17KB |
|
2 |
Windows RE 环境 |
512MB |
129MB |
T |
3 |
EFI 启动分区 |
260MB |
641MB |
U |
4 |
MSR |
128MB |
901MB |
|
5 |
Windows 系统盘 |
222GB |
1029MB |
W |
6 |
还原镜像 |
14GB |
223GB |
X |
(在磁盘管理中,它看起来像是只有四个分区,这是正常现象。)
安装 Windows
|
PS D:\> dism /apply-image /imagefile=D:\install.wim /index:1 /applydir:W:\ Deployment Image Servicing and Management tool Version: 10.0.16299.15 Applying image [==========================100.0%==========================] The operation completed successfully. |
安装 Windows Recovery
首先把需要的文件搞出来。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
PS D:\> mkdir D:\temp_system Directory: D:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2017-10-20 18:15 temp_system PS D:\> dism /mount-wim /wimfile:D:\install.wim /index:1 /mountdir:D:\temp_system /readonly Deployment Image Servicing and Management tool Version: 10.0.16299.15 Mounting image [==========================100.0%==========================] The operation completed successfully. |
复制恢复分区镜像和系统安装镜像。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
PS D:\> mkdir T:\Recovery\WindowsRE Directory: T:\Recovery Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2017-10-20 18:13 WindowsRE PS D:\> copy D:\temp_system\Windows\System32\Recovery\Winre.wim T:\Recovery\WindowsRE\Winre.wim PS C:\> mkdir X:\Recovery Directory: X:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2017-10-20 23:38 Recovery PS D:\> copy D:\install.wim X:\Recovery\install.wim |
创建 EFI 引导
|
PS C:\> bcdboot W:\Windows /s U: /f UEFI Boot files successfully created. PS C:\> reagentc /setosimage /path X:\Recovery /target W:\Windows /index 1 Directory set to: \\?\GLOBALROOT\device\harddisk4\partition6\Recovery REAGENTC.EXE: Operation Successful. PS C:\> reagentc /setreimage /path T:\Recovery\WindowsRE /target W:\Windows REAGENTC.EXE: Windows RE is already enabled. |
清理工作
在弹出移动硬盘之前,请务必移除分配给各系统分区的盘符,否则这个盘符会因为 Windows 的一些 bug 永远无法被移除,始终在资源管理器中显示一个空占位符。
|
PS C:\> mountvol T: /D PS C:\> mountvol U: /D PS C:\> mountvol W: /D PS C:\> mountvol X: /D |
卸载刚刚挂载的 WIM。
|
PS D:\> dism /unmount-wim /mountdir:D:\temp_system /discard Deployment Image Servicing and Management tool Version: 10.0.16299.15 Image File : D:\install.wim Image Index : 1 Unmounting image [==========================100.0%==========================] The operation completed successfully. PS D:\> rm D:\temp_system |
给目标设备准备驱动程序。如果你和我一样准备把这个 Windows 用在 Mac 上,那么需要事先使用 macOS 的 Boot Camp 助理下载对应的驱动程序。这个过程需要一个空白的,格式化成 MBR 分区/FAT32 的 U 盘。下载完后可以将文件直接复制到 Windows 系统分区中,就不需要再插 U 盘安装了。
接下来,把硬盘弹出,插到目标电脑上,选择该硬盘 EFI 启动,就会看到熟悉的 Windows 10 OOBE 向导了。
参考: