壓縮 OS、單一執行個體及映像最佳化Compact OS, single-instancing, and image optimization

Windows 10 包含可協助您使用較少磁片磁碟機空間的工具。Windows 10 includes tools to help you use less drive space. 您現在可以壓縮整個作業系統的檔案,包括預先載入的桌面應用程式。You can now compress the files for the entire operating system, including your preloaded desktop applications. Compact 作業系統可讓您從壓縮檔案執行作業系統, (類似 Windows 8.1 更新版 1) 的 WIMBoot,而單一實例可協助您在壓縮檔案中執行預先載入的 Windows 桌面應用程式。Compact OS lets you run the operating system from compressed files (similar to WIMBoot in Windows 8.1 Update 1), and single-instancing helps you run your pre-loaded Windows desktop applications in compressed files. 新的程式會使用個別的檔案,而不是將它們合併在 WIM 檔案中,以協助維護一段時間的較小使用量。The new processes helps maintain a small footprint over time by using individual files, rather than combining them in a WIM file.

以下是一些壓縮影像、將映射優化,以及部署至低成本裝置時的一些考慮的方式。Here's some ways to shrink the image, optimize the image, and some considerations when deploying to low-cost devices.

有助於節省空間的部署工具Deployment tools that help save space

Compact OSCompact OS

Compact OS 會將作業系統檔案安裝為壓縮檔案。Compact OS installs the operating system files as compressed files. UEFI 型和 BIOS 型裝置都支援 Compact OS。Compact OS is supported on both UEFI-based and BIOS-based devices. 請參閱下方的 大小比較表See the size comparison table below.

與 WIMBoot 不同的是,因為檔案不再合併為單一 WIM 檔案,Windows update 可以視需要取代或移除個別檔案,以協助維護一段時間的磁片磁碟機使用量。Unlike WIMBoot, because the files are no longer combined into a single WIM file, Windows update can replace or remove individual files as needed to help maintain the drive footprint size over time.

使用 WIM 檔案部署 Compact OSTo deploy Compact OS using a WIM file

  1. 使用 Windows PE 的 Windows 10 版本啟動目的地裝置。Boot your destination device with the Windows 10 version of Windows PE. (使用舊版的 Windows PE,請確定您使用的是 Windows 10 版本的 DISM。(To use a previous version of Windows PE, make sure you use the Windows 10 version of DISM. 若要深入瞭解,請參閱 將 DISM 複製到另一部電腦。 ) To learn more, see Copy DISM to Another Computer.)

  2. 建立相當於 256 MB 的分頁檔。Create a pagefile equal to 256 MB.

    Wpeutil createpagefile C:\pagefile /size=256
    

    其中 "C" 是 Windows 分割區。Where "C" is the Windows partition.

  3. 格式化和準備分割區,然後使用 DISM/Apply-Image/Compact 選項將映射套用至磁碟分割:Format and prepare the partitions, and then apply the image to a partition using the DISM /Apply-Image /Compact option:

    DISM /Apply-Image /ImageFile:install.wim /Index:1 /ApplyDir:D:\ /compact
    

    這通常是藉由執行部署腳本來完成。This is usually done by running a deployment script. 若要深入瞭解,請參閱 使用 DISM 套用影像To learn more, see Apply Images Using DISM.

    注意: 如果您要以精簡模式套用映射,並使用/ScratchDir 選項,請確定您的 ScratchDir 資料夾不在 FAT32 格式的磁碟分割上。Note: If you're applying an image in compact mode and using the /ScratchDir option, make sure your ScratchDir folder is not on a FAT32-formatted partition. 使用 FAT32 磁碟分割可能會在 OOBE 期間導致非預期的重新開機。Using a FAT32 partition could result in unexpected reboots during OOBE.

從 Windows 安裝程式部署 Compact OSTo deploy Compact OS from Windows Setup

  • 使用 unattend.xml 檔案與設定: Microsoft-Windows-安裝 \ ImageInstall \ OSImage \ CompactUse an unattend.xml file with the setting: Microsoft-Windows-Setup\ImageInstall\OSImage\Compact.

部署具有 USB 可開機磁片磁碟機的 Compact OSTo deploy Compact OS with a USB bootable drive

針對 Windows 10,1607版及更早版本For Windows 10, Version 1607 and earlier

  1. 在您的技術人員電腦上,開啟 Windows ICD 並建立您的專案。On your technician PC, open Windows ICD and create your project.
  2. 插上 USB 快閃磁片磁碟機,並記下磁碟機號 (範例: D: ) 。Plug in a USB flash drive and note the drive letter (example: D:).
  3. 按一下 [ 建立 > 生產媒體 > WIM > 啟用 OS 檔案壓縮:是 > 下一個 > USB 可開機磁碟機 > 號] (D: ) > 下一個 > 組建Click Create > Production Media > WIM > Enable OS File Compression: Yes > Next > USB Bootable drive > drive letter (D:) > Next > Build.
  4. 使用 USB 快閃磁片磁碟機啟動目的地電腦。Boot the destination PC using the USB flash drive. Windows 會自動安裝。Windows installs automatically.

注意 在執行舊版 Windows 的電腦上執行 Windows 映像處理與設定設計工具 (ICD) (例如 Windows 8.1)時,您必須安裝 Windows 評定及部署套件 (ADK) ,同時具備 Windows ICD 和 部署工具 的功能。Note When running Windows Imaging and Configuration Designer (ICD) on a PC running a previous version of Windows, such as Windows 8.1, you'll need to install the Windows Assessment and Deployment Kit (ADK) with both the Windows ICD and Deployment Tools features. 這會安裝 DISM ( # A0 所需的最新版本驅動程式,以及用來建立 Compact OS 映射的 adkwof.sys) 。This installs the latest versions of the drivers required by DISM (wimmount.sys and adkwof.sys) used to create Compact OS images.

從 FFU 映射部署 Compact OSTo deploy Compact OS from an FFU image

針對 Windows 10,1607版及更早版本For Windows 10, Version 1607 and earlier

  1. 若要將 FFU 映射部署為壓縮,必須將原始 FFU 映射建立為壓縮的影像。To deploy an FFU image as compressed, the original FFU image must be created as a compressed image.

    在 Windows ICD 中,按一下 [ 建立 > 生產媒體 > FFU > 啟用 OS 檔案壓縮:是 檔案 > 的名稱,例如 D: \ FFU > 組建 ]。From Windows ICD, click Create > Production Media > FFU > Enable OS File Compression: Yes > name the file, for example, D:\flash.ffu > Build.

  2. 您可以從 Windows ICD 或 Windows 預先安裝環境 (WinPE) 將 FFU 映射直接部署到磁片磁碟機。You can deploy the FFU image directly to a drive from Windows ICD or from Windows Preinstallation Environment (WinPE). 若要深入瞭解,請參閱 使用 Full Flash Update 部署 Windows (FFU) To learn more, see Deploy Windows using Full Flash Update (FFU).

注意 在執行舊版 Windows 的電腦上執行 Windows 映像處理與設定設計工具 (ICD) (例如 Windows 8.1)時,您必須安裝 Windows 評定及部署套件 (ADK) ,同時具備 Windows ICD 和 部署工具 的功能。Note When running Windows Imaging and Configuration Designer (ICD) on a PC running a previous version of Windows, such as Windows 8.1, you'll need to install the Windows Assessment and Deployment Kit (ADK) with both the Windows ICD and Deployment Tools features. 這會安裝 DISM ( # A0 所需的最新版本驅動程式,以及用來建立 Compact OS 映射的 adkwof.sys) 。This installs the latest versions of the drivers required by DISM (wimmount.sys and adkwof.sys) used to create Compact OS images.

命令列支援Command-line support

您可以使用 Compact.exe 命令,查詢作業系統是否正在執行 Compact OS,並隨時變更。You can query whether the operating system is running Compact OS, and change it at any time, using the Compact.exe command.

從 Windows PE,判斷是否已壓縮作業系統:From Windows PE, determine if the OS is compacted:

Compact.exe /CompactOS:Query /WinDir:E:\Windows

其中 E: \ windows 是安裝 windows 的資料夾。Where E:\Windows is the folder where Windows has been installed.

從線上安裝,將非壓縮的變更為壓縮的作業系統:From an online installation, change from non-compacted to compacted OS:

Compact.exe /CompactOS:always

布建套件的單一實例Single-instancing of provisioning packages

針對 Windows 10,當您將新的 Windows 桌面應用程式新增至裝置時,您會將這些變更捕捉到壓縮的布建套件,以供自動復原工具使用。For Windows 10, when you add new Windows desktop applications to a device, you'll capture these changes into a compressed provisioning package for use by the automatic recovery tools. 您可以改為使用 DISM 來移除原始檔案,然後直接從壓縮的布建套件中執行,而不是同時維護原始檔案和布建套件。Rather than maintaining both the original files and the provisioning package, you can use DISM to remove the original files, and run from directly from the compressed provisioning package instead. 這稱為影像的單一實例。This is known as single-instancing the image. 請參閱下方的 大小比較表See the size comparison table below.

雖然固態硬碟和旋轉磁片磁碟機都支援單一實例,但基於效能的考慮,建議您只在具有固態硬碟的裝置上使用單一實例。While single-instancing is supported on both solid-state drives and rotational drives, for performance reasons, we recommend that single-instancing is only used on devices with solid-state drives.

範例:Example:

DISM /Apply-CustomDataImage /CustomDataImage:C:\Recovery\Customizations\USMT.ppkg /ImagePath:C:\ /SingleInstance

其中 C 是 Windows 磁碟分割的磁碟機號。where C is the drive letter of the Windows partition.

警告 請勿使用/ImagePath: C:選項來放置引號 \ 。Warning Do not put quotes with the /ImagePath:C:\ option.

您可以使用 fsutil.exe,判斷 ppkg) 的布建 ( 套件是否為單一實例:You can determine whether a provisioning package (.ppkg) is single-instanced by using fsutil.exe:

fsutil.exe wim enumwims C:

其中 C 是包含布建套件的磁片磁碟機。where C is the drive that contains the provisioning package. 磁片磁碟機上的任何單一實例布建套件都會列在命令輸出中。Any single-instanced provisioning package on the drive will be listed in the command output. 如果沒有,此命令會傳回「錯誤:系統找不到指定的檔案。」If there are none, the command will return "Error: The system cannot find the file specified."

影像優化Image optimization

將更新套用至 Windows 映像之後,請清除該映射,然後將它匯出至新的檔案:After applying updates to a Windows image, cleanup the image and then export it to a new file:

md c:\mount\Windows
md C:\mount\temp

Dism /Mount-Image /ImageFile:"C:\Images\install.wim" /Index:1 /MountDir:C:\mount\Windows

Dism /Cleanup-Image /Image=C:\mount\Windows /StartComponentCleanup /ResetBase /ScratchDir:C:\mount\temp

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

Dism /Export-Image /SourceImageFile:C:\Images\install.wim /SourceIndex:1 /DestinationImageFile:C:\Images\install_cleaned.wim

其中 C: \ 映射 \ 安裝。 wim 是您想要更新的 Windows 映像檔案。where C:\Images\install.wim is a Windows image file that you want to update. 從 Windows 10 (1607版)開始,您可以選擇性地使用/ResetBase 指定/Defer 參數,將任何長時間執行的清除作業延遲到下一個自動維護,但強烈建議您 在 DISM/ResetBase 需要30分鐘以上才能完成的情況下,使用/Defer 做為選項。Beginning with Windows 10, version 1607, you can optionally specify the /Defer parameter with /ResetBase to defer any long-running cleanup operations to the next automatic maintenance, but we highly recommend that only use /Defer as an option in the factory where DISM /ResetBase requires more than 30 minutes to complete.

大小需求和考慮Size requirements and considerations

您仍然需要符合硬碟、RAM、應用程式資源使用量和資料儲存體的最小大小需求。You'll still need to meet minimum size requirements for the hard drive, RAM, application resource usage, and data storage.

硬碟Hard Drive

Windows 10 需要32位裝置上至少 16 gb 的 (GB) 空間,以及64位裝置上的 20 GB。Windows 10 requires a minimum of 16 gigabytes (GB) of space on 32-bit devices, and 20 GB on 64-bit devices.

雖然 windows 初次安裝時,某些 Windows 設定可能會顯示在較小的磁片磁碟機上,但 8 GB 的 Ssd 不夠大。Although some configurations of Windows may appear to fit on smaller drives when Windows is first installed, 8 GB SSDs are not large enough. 即使使用者針對應用程式和資料檔案儲存體將 8 GB 的硬碟與第二個磁片磁碟機配對,也不允許 8 GB 的硬碟在使用者在電腦上執行時所需的 Windows 記憶體使用量增加。Even if a user pairs an 8 GB hard drive with a second drive that is 4 GB or larger for application and data file storage, 8 GB hard drives do not allow for the increase in the Windows memory footprint that is expected to occur as users work on their computer.

在記憶體使用量中隨著時間增加的主要原因包括下列各項:Some of the primary reasons for the increase over time in the memory footprint include the following:

  • 服務Servicing. 硬碟空間必須保留給作業系統和 service pack 版本的軟體修補程式。Hard disk space must be reserved for software patches to the operating system and for service pack releases.

  • 系統還原點System Restore Points. Windows 會自動產生還原點。Windows automatically generate restore points. 預設需要的空間量是相對於硬碟的大小。The amount of space that is required by default is relative to the size of the hard drive. 如需還原點的詳細資訊,請參閱 MSDN 上的 還原點 主題。For more information about restore points, see the Restore Points topic on MSDN. 注意 使用者可以使用 [ 系統 內容] 對話方塊中的 [ 系統保護 ] 使用者介面, ( # A0) ,來調整電腦上用來系統還原的空間量。Note Users can adjust the amount of space used on the computer for System Restore by using the System Protection user interface in the System Properties dialog box (Sysdm.cpl). 使用者也可以使用儲存在外部硬碟的系統映射備份來還原系統。Users can also use system image backups that are stored on an external hard disk to restore a system.

  • 記錄和 快取。Logs and Caches. 作業系統會將檔案(例如事件記錄檔和錯誤記錄檔)儲存在磁片磁碟機上。The operating system stores files such as event logs and error logs on the drive.

RAM、Pagefile.sys 和 Hiberfil.sysRAM, Pagefile.sys, and Hiberfil.sys

Pagefile.sys 和 Hiberfil.sys 檔案的大小會以與電腦上 RAM 數量的直接比例增加。The Pagefile.sys and Hiberfil.sys files increase in size in direct proportion to the amount of RAM on the computer. 當電腦受限於 1 GB 的 RAM 時,16 GB 磁片磁碟機上的 Windows 安裝會有較小的記憶體使用量。Windows installations on 16 GB drives have a smaller memory footprint when the computer is limited to 1 GB of RAM. 將 RAM 增加到大於 1 GB 的大小,將會導致系統檔案的大小增加,以及其他應用程式和檔案的硬碟空間較少。An increase of RAM to a size that is greater than 1 GB will result in increased size of the system files and less space on the hard drive for other applications and files. 不過,增加硬碟的大小並不會影響這些系統檔案的大小。Increasing the size of the hard drive, however, does not affect the size of these system files. 深入瞭解如何 開啟/關閉轉換效能Learn more about On/Off Transition Performance

若要節省磁片磁碟機上的空間,您可以移除或縮減 hiberfil.sys 的大小。To save space on the drive, you can remove or reduce the size of the hiberfil.sys. 請參閱下方的 大小比較表See the size comparison table below. 若要深入瞭解,請參閱 實驗室7:變更設定、輸入產品金鑰,以及使用回應檔案執行腳本 ( # A0) To learn more, see Lab 7: Change settings, enter product keys, and run scripts with an answer file (unattend.xml).

  • powercfg /h /type reduced :減少30% 的檔案powercfg /h /type reduced : Reduces the file by 30%
  • powercfg /h off :移除檔案。powercfg /h off : Removes the file.

隨選語言套件和功能Language packs and features on demand

已安裝的語言套件 (LPs) 所需的空間可能比 LP 本身的大小還多。Installed language packs (LPs) can take more space than just the size of the LP itself. 當您在包含多個 LPs 的 Windows 安裝上預先安裝 Fod 和 UWP 應用程式時,也會安裝以預先安裝的 LPs 為基礎的資源檔。When you preinstall FODs and UWP apps on a Windows installation that contains multiple LPs, resource files based on preinstalled LPs are also installed. 在 OOBE 之後自動移除未使用的語言時,對應的 UWP 和隨選功能 (FOD) 資源檔不會移除。When unused languages are automatically removed after OOBE, corresponding UWP and feature on demand (FOD) resource files are not removed. 藉由限制移除未使用的語言套件之後,在系統上保留的資源檔數目,來預先安裝較少的 LPs 可節省磁碟空間。Preinstalling fewer LPs saves disk space by limiting the number of resource files that remain on a system after removing unused language packs.

隨選功能會散佈在壓縮的封包檔中,因此安裝的 FOD 大小會大於原始 CAB 的大小。Features on demand are distributed in compressed CAB files so the size of an installed FOD is larger than the size of the original CAB. 您可以使用 /Get-CapabilityInfo DISM 來查看 FOD 的下載和安裝大小。You can use /Get-CapabilityInfo in DISM to view an FOD's download and install sizes. 如需如何取得 Fod 相關資訊,請參閱 隨選功能See Features on demand for how to get information about FODs.

應用Applications

電腦上安裝的軟體應用程式可能需要額外的空間來進行快取、記錄和更新。Software applications that are installed on the computer may require additional space for caches, logs, and updates. 磁碟空間也必須在磁片磁碟機上提供,以在安裝應用程式、修補程式和更新期間暫時增加資源使用量。Disk space must also be available on the drive to account for temporary increases in resource usage during installation of applications, patches, and updates.

使用者資料User Data

在支援卸載式媒體(例如 SD 記憶卡或 USB 快閃磁片磁碟機)的電腦上,使用者可以使用此卸載式媒體,輕鬆地擴充使用者檔的個人資料檔案儲存體。On computers that support removable media such as an SD card or USB flash drive, users can easily expand personal data file storage for user documents by using this removable media. 不過,我們建議使用者針對這些類型的檔案,保留硬碟上的一些空間。However, we recommend that users reserve some space on the hard drive for these types of files.

大小比較Size comparisons

下表顯示使用 compact OS 儲存的額外空間、單一實例,並減少或關閉 2GB (x86 處理器架構) 和 4GB (x64 處理器架構) Windows 10 1607 版上的 Hiberfile:The table below shows the additional space saved by using compact OS, Single instancing, and reducing or turning Off Hiberfile on 2GB (x86 processor architecture) and 4GB (x64 processor architecture), on Windows 10, version 1607:

映像Image Windows 10 家用版 x86、2GB 記憶體Windows 10 Home x86, 2GB memory Windows 10 家用版 x64、4GB 記憶體Windows 10 Home x64, 4GB Memory
基底使用量Base Footprint 11.68 GB11.68GB 15.06 GB15.06GB
Compact OS,沒有單一實例Compact OS, with no single instancing 8.85 GB ( # B0 2.75 GB 節省) 8.85GB (>2.75GB savings) 11.3 GB ( # B0 3.7 GB) 11.3GB (>3.7GB)
Compact 作業系統,單一實例Compact OS, single instanced 7.66 GB ( # B0 4) 7.66GB (>4GB) 10.09 GB ( # B0 4.75 GB) 10.09GB (>4.75GB)
Hiberfile off,沒有 compact OSHiberfile off, no compact OS 10.87 GB ( # B0 825MB) 10.87GB (>825MB) 13.48 GB ( # B0 1.5 GB) 13.48GB (>1.5GB)
Hiberfile 縮減,無 compact 作業系統Hiberfile reduced, no compact OS 11.27 GB ( # B0 400MB) 11.27GB (>400MB) V14.15 GB ( # B0 930MB) 14.15GB (>930MB)

相關主題Related topics

Windows 映像處理與設定設計工具Windows Imaging and Configuration Designer

捕獲並套用 Windows、系統和修復磁碟分割Capture and Apply Windows, System, and Recovery Partitions

DISM 映像管理命令列選項DISM Image Management Command-Line Options