Create WIMBoot Images

Windows image file boot (WIMBoot) 最大的優點就是可以減少系統的使用容量,一般以正常的方式安裝Windows作業系統,以Windows 8.1為例需要至少10GB以上的空間,這還不包含安裝更新和其他應用程式所用的空間,當然在這硬碟便宜的時代,其實10GB以1 TB硬碟來說占用的比例真的不多。

 

建置需求:


如果環境中有以下幾個需求,那就可以考慮建置WIMBoot:

1. WIMBoot除了參照來源檔案大約4GB,在C碟排除分頁檔(pagefile.sys),大約只會需要1GB的基本空間,所以在大量佈署上就會減少花費的時間。



2. 使用容量不大的SSD硬碟


WIMBoot和標準安裝的示意圖:


標準安裝



WIMBoot



  • Images partition:放置壓縮的映像檔,包含install.wim、winre.wim、custom.wim

  • Windows partition:除了pointer files還放置使用者設定檔、個人資料、分頁檔等其他檔案。




 

WIMBoot的限制:


1. 目前僅支援Windows 8.1 with Update,且不支援Server版本

2. 僅可以執行在UEFI mode的電腦上,傳統的legacy BIOS-compatibility mode不支援

3. 可能會有防毒、備份和加密軟體不支援WIMBoot

4. 為了節省硬碟空間將不會收到November Update (KB3000850)更新,但還是可以手動下載安裝

5. 不建議系統使用超過32GB的儲存空間

 

前置準備:


1. 包含Windows 8.1 with Update的WIM檔案,建議直接從已經整合完畢的官方安裝光碟提取。

2. 準備一台電腦並安裝Windows Assessment and Deployment Kit (Windows ADK)

3. Windows PE 5.1

 

製作WIMBoot印象檔:


官方有提供兩個方法,方法一步驟較繁瑣並作系統的清理,優點是WIM可以更小,方法二步驟簡單且不需要額外的參照電腦,官方比較推薦使用方法一。

 

方法一:Create a WIMBoot-optimized image


複製install.wim到暫存資料夾


從已經整合Windows 8.1 with Update的光碟中,將install.wim複製出來
md C:\Images\
Copy E:\sources\install.wim C:\Images\install_temp.wim


將Windows RE image從Windows image分離


1. 建立掛載印象檔的資料夾,並將install_temp.wim掛載到C:\mount\Windows
md C:\mount\Windows
Dism /Mount-Image /ImageFile:"C:\Images\install_temp.wim" /Index:1 /MountDir:C:\mount\Windows

2. 取消隱藏Windows RE image (winre.wim)
attrib -s -h -r C:\mount\Windows\Windows\System32\Recovery\winre.wim

3. 移動winre.wim到C:\images\
move C:\mount\Windows\Windows\System32\Recovery\winre.wim C:\images\winre.wim

 

優化Windows image


優化Windows image並取得更多空間
Dism /Optimize-Image /Image:C:\mount\Windows /WIMBoot

 

卸載image


卸載Windows image
Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit

 

準備參照電腦的硬碟環境


要注意的是只能使用UEFI and GPT-based的電腦,如果是透過Hyper-V製作必須選擇第二代的虛擬機器,這個功能只支援在Server 2012 R2和Windows 8.1以上的作業系統。

 

1. 如果是透過VM來製作,建議可以在上個步驟掛載另一顆VHD,並將C:\Images\install_temp.wim 和 C:\images\winre.wim 先複製到這棵VHD上,再將這顆硬碟掛載到目前的參照電腦上,如果是透過實體電腦建議就用USB外接硬碟的方式。

2. 將以下的指令儲存在CreatePartitions.txt中,一起放進這顆外接硬碟中
rem == CreatePartitions-UEFI.txt ==
rem == These commands are used with DiskPart to
rem create five partitions
rem for a UEFI/GPT-based PC.
rem Adjust the partition sizes to fill the drive
rem as necessary. ==
select disk 0
clean
convert gpt
rem == 1. Windows RE tools partition ===============
create partition primary size=300
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
rem == 2. System partition =========================
create partition efi size=100
rem ** NOTE: For Advanced Format 4Kn drives,
rem change this value to size = 260 **
format quick fs=fat32 label="System"
assign letter="S"
rem == 3. Microsoft Reserved (MSR) partition =======
create partition msr size=128
rem == 4. Windows partition ========================
rem == a. Create the Windows partition ==========
create partition primary
rem == b. Create space for the recovery image ===
shrink minimum=15000
rem ** NOTE: Update this size to match the size
rem of the recovery image **
rem == c. Prepare the Windows partition =========
format quick fs=ntfs label="Windows"
assign letter="W"
rem === 5. Recovery image partition ================
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
exit

3. 將以下的指令儲存在ApplyImage.bat中,一起放進這顆外接硬碟中
rem These commands copy the selected image file to
rem predefined hard disk partitions on a UEFI-based computer.
rem Usage: ApplyImage WimFileName
rem Example: ApplyImage C:\Images\install_temp.wim
rem === Copy the image to the recovery image partition =======================
md R:\Images
copy %1 R:\Images\install.wim
rem === Apply the image to the Windows partition =============================
dism /Apply-Image /ImageFile:R:\Images\install.wim /Index:1 /ApplyDir:W:\
rem === Copy the Windows RE Tools to the Windows RE Tools partition ==========
md T:\Recovery\WindowsRE
copy %2 T:\Recovery\WindowsRE\winre.wim
rem === Copy boot files from the Windows partition to the System partition ===
bcdboot W:\Windows
rem === In the System partition, set the location of the Windows partition ===
W:\Windows\System32\reagentc /setosimage /path R:\Images /target W:\Windows /index 1
rem === In the System partition, set the location of the WinRE tools =========
W:\Windows\System32\reagentc /setreimage /path T:\Recovery\WindowsRE /target W:\Windows

4. 將外接硬碟或VHD掛載在參照電腦,並使用Windows PE 5.1開機進入WinPE,一般如果是有磁區的硬碟,都會優先排列在C碟,如果不是在C碟就必須透過指令diskpart作變更,再透過以下指令去切割磁區和套用印象檔,套用印象檔第一個放置install_temp.wim路徑,第二個放置winre.wim路徑,如果路徑中有空白請用雙引號框住。
diskpart /s C:\CreatePartitions.txt


ApplyImage C:\Images\install_temp.wim C:\images\winre.wim

5. 套用完畢重新開機進入OOBE

 

清除image並擷取WIMBoot映像檔


1. 進入到OOBE的畫面請不要選擇語言、輸入法和時區,直接按鍵盤的 CTRL+SHIFT+F3 會自動重開機進入稽核模式(audit mode)

2. 這個步驟可依照個人需求選擇是否移除內建Windows Apps,如果需要移除請用系統管理員身分執行PowerShell,並輸入以下指令進行移除,如果需要保留請直接到下一步驟。
Get-AppXProvisionedPackage -online | Remove-AppxProvisionedPackage –online

3. 用系統管理員身分執行cmd輸入以下指令進行系統的清理
Dism /Cleanup-Image /Online /StartComponentCleanup

4. 再次執行封裝,封裝完畢會自動關機
C:\Windows\System32\Sysprep\sysprep /generalize /shutdown /oobe

5. 再次開機進入Windows PE 5.1,如果不小心進入了OOBE,必須再重新執行步驟三的sysprep指令。

6. 建立temporary scratch directory
md C:\Recycler\Scratch

7. 將參照電腦重新擷取成WIM映像檔,加入參數/WIMBoot讓這映像檔可以有WIMBoot功能
DISM /Capture-Image /WIMBoot /ImageFile:"D:\Images\install_wimboot.wim" /CaptureDir:C: /Name:"WIMBoot Enterprise_x64 with 8.1 Updates" /ScratchDir:C:\Recycler\Scratch

 

方法二:Add WIMBoot support to a standard image


方法二可以直接針對現存WIM檔案做匯出並加入WIMBoot功能,但缺點是WIM會比較大,但如果手邊沒有winre.wim檔案,還是需要從install.wim擷取出來。

 

複製install.wim到暫存資料夾


從已經整合Windows 8.1 with Update的光碟中,將install.wim複製出來,接下來的步驟如果已經先擷取出winre.wim檔案,可以直接跳過以下三個步驟,直接到"擷取image並加入WIMBoot功能"這個步驟,缺點是winre.wim還是包含在install.wim中,所以檔案會比較大差異大約300MB的空間
Copy E:\sources\install.wim C:\Images\install_temp.wim

 

將Windows RE image從Windows image分離


1. 建立掛載印象檔的資料夾,並將install_temp.wim掛載到C:\mount\Windows
md C:\mount\Windows
Dism /Mount-Image /ImageFile:"C:\Images\install_temp.wim" /Index:1 /MountDir:C:\mount\Windows

2. 取消隱藏Windows RE image (winre.wim)
attrib -s -h -r C:\mount\Windows\Windows\System32\Recovery\winre.wim

3. 移動winre.wim到C:\images\
move C:\mount\Windows\Windows\System32\Recovery\winre.wim C:\images\winre.wim

 

優化Windows image


優化Windows image並取得更多空間
Dism /Optimize-Image /Image:C:\mount\Windows /WIMBoot

 

卸載image


卸載Windows image
Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit

 

擷取image並加入WIMBoot功能


重新匯出WIM映像檔,並加入參數/WIMBoot讓這映像檔可以有WIMBoot功能
Dism /Export-Image /WIMBoot /SourceImageFile:C:\Images\install_temp.wim /SourceIndex:1 /DestinationImageFile:C:\Images\install_wimboot.wim

 

確認wim是否包含WIMBoot功能


同樣是透過Dism指令查詢
Dism /Get-ImageInfo /imagefile:C:\Images\install.wim /Index:1



 

參考資料:

Windows Image File Boot (WIMBoot) Overview

Create WIMBoot Images

Samples: Applying Windows, System, and Recovery Partitions by using a Deployment Script

Sample: Configure UEFI/GPT-Based Hard Drive Partitions by Using Windows PE and DiskPart

留言

  1. Casino Site Review and Ratings - Lucky Club
    Casino Site Review — There are quite a few online casino sites luckyclub.live to choose from including: Betway, PokerStars, and many others. With more than 50

    回覆刪除

張貼留言

這個網誌中的熱門文章

如何重新設定新的Outlook電子郵件帳戶