更新 Nano ServerUpdating Nano Server

重要

從 Windows Server 版本 1709 開始,Nano Server 僅以容器基礎 OS 映像的形式來提供。Starting in Windows Server, version 1709, Nano Server will be available only as a container base OS image. 請查看 Nano Server 的變更以了解這代表的意義。Check out Changes to Nano Server to learn what this means.

Nano Server提供各種不同保持最新版本的方法。Nano Server offers a variety of methods for staying up to date. 相較於 WindowsServer 其他安裝選項,Nano Server 遵循更為主動的服務模型。類似 Windows10。Compared to other installation options of Windows Server, Nano Server follows a more active servicing model similar to that of Windows 10. 這些定期版本稱為目前商業分支 (CBB) 版本。These periodic releases are known as Current Branch for Business (CBB) releases. 這種方式可支援想要創新更迅速,並以雲端發佈頻率跟上快速開發週期的客戶。This approach supports customers who want to innovate more quickly and move at a cloud cadence of rapid development lifecycles. 您可以從 WindowsServer 部落格上取得更多 CBB 的相關資訊。More information about CBB is available on the Windows Server Blog.

在這些 CBB 版本之間,Nano Server 會以一系列的累積更新保持在最新狀態。Between these CBB releases, Nano Server stays current with a series of cumulative updates. 例如,Nano Server 的第一個累積更新發佈於 2016 年 9 月 26 日,搭配 KB3192366For example, the first cumulative update for Nano Server was released on September 26, 2016 with KB3192366. 我們提供在 Nano Server 上安裝此一更新和後續累積更新的各種選項。With this and subsequent cumulative updates, we provide various options for installing these updates on Nano Server. 在本文中,我們將使用 KB3192366 更新做為範例,說明如何取得並將累積更新套用到 Nano Server。In this article, we'll use the KB3192366 update as an example to illustrate how to obtain and apply cumulative updates to Nano Server. 如需有關累積更新模型的詳細資訊,請參閱 Microsoft Update 部落格For more information on the cumulative update model, see the Microsoft Update blog.

注意

如果您是從媒體或線上存放庫安裝選用的 Nano Server 套件,它並不會包含最新的安全性問題修正。If you install an optional Nano Server package from media or online repository, it won't have recent security fixes included. 若要避免選用套件和基本作業系統之間的版本不符,您應該在安裝任何選用套件之後和重新啟動伺服器之前,立即安裝最新的累積更新。To avoid a version mismatch between the optional packages and base operating system, you should install the latest cumulative update immediately after installing any optional packages and before restarting the server.

以 WindowsServer 2016:2016 年 9 月 26 日 (KB3192366) 的累積更新為例,您應該將最新的 Windows10 版本 1607:2016 年 8 月 23日 (KB3176936) 服務堆疊更新視為必要條件並先行安裝。In the case of the Cumulative Update for Windows Server 2016: September 26, 2016 (KB3192366), you should first install the latest Servicing Stack Update for Windows 10 Version 1607: August 23, 2016 as a prerequisite (KB3176936). 下方大部分選項,您都需要包含 .cab 更新套件的.msu 檔案。For most of the options below, you need the .msu files containing the .cab update packages. 請造訪 Microsoft Update Catalog 下載每個更新套件︰Visit the Microsoft Update Catalog to download each of these update packages:

從 Microsoft Update Catalog 下載 .msu 檔案後,請將它們儲存到網路共用或本機目錄,例如 C:\ServicingPackages。After downloading the .msu files from the Microsoft Update Catalog, save them to a network share or local directory such as C:\ServicingPackages. 您可以根據它們的 KB 號碼來重新命名 .msu 檔案,如下方所示,將可更容易識別它們。You can rename the .msu files based on their KB number as we've done below to make them easier to identify. 然後使用 Expand 公用程式將 .msu 檔案中的 .cab 檔案解壓縮進獨立的目錄,再將這些 .cab 複製到單一資料夾中。Then use the EXPAND utility to extract the .cab files from the .msu files into separate directories and copy the .cabs into a single folder.

    mkdir C:\ServicingPackages_expanded
    mkdir C:\ServicingPackages_expanded\KB3176936
    mkdir C:\ServicingPackages_expanded\KB3192366
    Expand C:\ServicingPackages\KB3176936.msu -F:* C:\ServicingPackages_expanded\KB3176936
    Expand C:\ServicingPackages\KB3192366.msu -F:* C:\ServicingPackages_expanded\KB3192366
    mkdir C:\ServicingPackages_cabs
    copy C:\ServicingPackages_expanded\KB3176936\Windows10.0-KB3176936-x64.cab C:\ServicingPackages_cabs
    copy C:\ServicingPackages_expanded\KB3192366\Windows10.0-KB3192366-x64.cab C:\ServicingPackages_cabs

現在您可以根據需求,使用數個不同的方式透過已解壓縮的 .cab 檔案將更新套用至 Nano Server 映像。Now you can use the extracted .cab files to apply the updates to a Nano Server image in a few different ways, depending on your needs. 下列選項並非以特定的偏好順序顯示,請使用最適合您環境的選項。The following options are presented in no particular order of preference - use the option that makes the most sense for your environment.

注意

使用 DISM 工具服務 Nano Server 時,您必須使用與正在服務的 Nano Server 版本相同或較新版本的 DISM 的版本。When using the DISM tools to service Nano Server, you must use a version of DISM that is the same as or newer than the version of Nano Server you're servicing. 您可以藉由從相同版本的 Windows 執行 DISM、安裝相同版本的 Windows 評定及部署套件 (ADK),或在 Nano Server 本身執行 DISM 來達到此目的。You can achieve this by running DISM from a matching version of Windows, installing a matching version of the Windows Asssessment and Deployment Kit (ADK), or running DISM on Nano Server itself.

選項 1:整合累積更新至新的映像Option 1: Integrate a cumulative update into a new image

如果您正在建立新的 Nano Server 映像,您可以直接整合最新的累積更新到映像中,讓其在第一次開機時就已經完全修補。If you are building a new Nano Server image, you can integrate the latest cumulative update directly into the image so that it's fully patched on first boot.

New-NanoServerImage -ServicingPackagePath 'C:\ServicingPackages_cabs\Windows10.0-KB3176936-x64.cab', 'C:\ServicingPackages_cabs\Windows10.0-KB3192366-x64.cab' -<other parameters>

選項 2:整合累積更新至現有的映像Option 2: Integrate a cumulative update into an existing image

如果您已有作為建立 Nano Server 特定執行個體基準的 Nano Server 映像,您可以直接整合最新的累積更新到基準映像中,讓使用該映像建立的機器在第一次開機時就已經完全修補。If you have an existing Nano Server image that you use as a baseline for creating specific instances of Nano Server, you can integrate the latest cumulative update directly into your existing baseline image so that machines created using the image are fully patched on first boot.

Edit-NanoServerImage -ServicingPackagePath 'C:\ServicingPackages_cabs\Windows10.0-KB3176936-x64.cab', 'C:\ServicingPackages_cabs\Windows10.0-KB3192366-x64.cab' -TargetPath .\NanoServer.wim

選項 3:套用累積更新至現有的離線 VHD 或 VHDXOption 3: Apply the cumulative update to an existing offline VHD or VHDX

如果您已有虛擬硬碟 (VHD 或 VHDX),您可以使用 DISM 工具將更新套用到虛擬硬碟。If you have an existing virtual hard disk (VHD or VHDX), you can use the DISM tools to apply the update to the virtual hard disk. 您會需要確定該磁碟並非正在使用中,請關閉任何正在使用該磁碟的 VM 或卸載虛擬硬碟檔案。You need to make sure the disk is not in use either by shutting down any VMs using the disk or unmounting the virtual hard disk file.

  • 使用 PowerShellUsing PowerShell

    Mount-WindowsImage -ImagePath .\NanoServer.vhdx -Path .\MountDir -Index 1
    Add-WindowsPackage -Path .\MountDir -PackagePath  C:\ServicingPackages_cabs
    Dismount-WindowsImage -Path .\MountDir -Save
    
  • 使用 dism.exeUsing dism.exe

    dism.exe /Mount-Image /ImageFile:C:\NanoServer.vhdx /Index:1 /MountDir:C:\MountDir
    dism.exe /Image:C:\MountDir /Add-Package /PackagePath:C:\ServicingPackages_cabs
    dism.exe /Unmount-Image /MountDir:C:\MountDir /Commit
    

選項 4:套用累積更新至正在執行的 Nano ServerOption 4: Apply the cumulative update to a running Nano Server

如果您擁有正在執行的 Nano Server VM 或實體主機,且您已下載作為更新的 .cab 檔案,您可以使用 DISM 工具以讓作業系統仍在線上時進行更新。If you have a running Nano Server VM or physical host and you've downloaded the .cab file for the update, you can use the DISM tools to apply the update while the operating system is online. 您將會需要從本機複製 .cab 檔案至 Nano Server 或至可存取的網路位置。You will need to copy the .cab file locally on the Nano Server or to an accessible network location. 如果您正在套用服務堆疊更新,請確定在套用服務堆疊更新後重新啟動此伺服器,再套用其他更新。If you're applying a servicing stack update, make sure to restart the server after applying the servicing stack update before applying additional updates.

注意

如果您已使用 NanoServerImage Cmdlet 建立 Nano Server VHD 或 VHDX 映像,但並未為虛擬硬碟檔案指定 MaxSize,預設 4GB 的大小將因為空間不足而無法套用累積更新。If you've created the Nano Server VHD or VHDX image using the New-NanoServerImage cmdlet and didn't specify a MaxSize for the virtual hard disk file, the default size of 4GB is too small to apply the cumulative update. 在安裝更新前,請使用 Hyper-V 管理員、磁碟管理、PowerShell 或其他工具擴展虛擬硬碟和系統磁碟區的大小至最少 10GB,或使用 DISM 工具的 ScratchDir 參數將暫存目錄設至擁有至少 10GB 可用空間的磁碟區。Prior to installing the update, use Hyper-V Manager, Disk Management, PowerShell, or other tool to expand the size of the virtual hard disk and system volume to at least 10GB, or use the ScratchDir parameter on the DISM tools to set the scratch directory to a volume with at least 10GB of free space.

$s = New-PSSession -ComputerName (Read-Host "Enter Nano Server IP address") -Credential (Get-Credential)
Copy-Item -ToSession $s -Path C:\ServicingPackages_cabs -Destination C:\ServicingPackages_cabs -Recurse
Enter-PSSession $s
  • 使用 PowerShellUsing PowerShell

    # Apply the servicing stack update first and then restart
    Add-WindowsPackage -Online -PackagePath C:\ServicingPackages_cabs\Windows10.0-KB3176936-x64.cab
    Restart-Computer; exit
    
    # After restarting, apply the cumulative update and then restart
    Enter-PSSession -ComputerName (Read-Host "Enter Nano Server IP address") -Credential (Get-Credential)
    Add-WindowsPackage -Online -PackagePath C:\ServicingPackages_cabs\Windows10.0-KB3192366-x64.cab
    Restart-Computer; exit
    
  • 使用 dism.exeUsing dism.exe

    # Apply the servicing stack update first and then restart
    dism.exe /Online /Add-Package /PackagePath:C:\ServicingPackages_cabs\Windows10.0-KB3176936-x64.cab
    
    # After the operation completes successfully and you are prompted to restart, it's safe to
    # press Ctrl+C to cancel the pipeline and return to the prompt
    Restart-Computer; exit
    
    # After restarting, apply the cumulative update and then restart
    Enter-PSSession -ComputerName (Read-Host "Enter Nano Server IP address") -Credential (Get-Credential)
    dism.exe /Online /Add-Package /PackagePath:C:\ServicingPackages_cabs\Windows10.0-KB3192366-x64.cab
    Restart-Computer; exit
    

選項 5:下載並安裝累積更新至正在執行的 Nano ServerOption 5: Download and install the cumulative update to a running Nano Server

如果您擁有正在執行的 Nano Server VM 或實體主機,您可以使用 Windows Update WMI 提供者讓作業系統仍在線上時下載和安裝更新。If you have a running Nano Server VM or physical host, you can use the Windows Update WMI provider to download and install the update while the operating system is online. 若使用此方法,您不需要從 Microsoft Update Catalog 分別下載 .msu 檔案。With this method, you don't need to download the .msu file separately from the Microsoft Update Catalog. WMI 提供者會同時偵測、下載和安裝所有可用的更新。The WMI provider will detect, download, and install all available updates at once.

Enter-PSSession -ComputerName (Read-Host "Enter Nano Server IP address") -Credential (Get-Credential)
  • 掃描所有可用的更新Scan for available updates

    $ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession  
    $result = $ci | Invoke-CimMethod -MethodName ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=0";OnlineScan=$true}
    $result.Updates
    
  • 安裝所有可用的更新Install all available updates

    $ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession
    Invoke-CimMethod -InputObject $ci -MethodName ApplyApplicableUpdates
    Restart-Computer; exit
    
  • 取得已安裝更新的清單Get a list of installed updates

    $ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession
    $result = $ci | Invoke-CimMethod -MethodName ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=1";OnlineScan=$true}
    $result.Updates
    

其他選項Additional Options

更新 Nano Server 的其他方法可能會與上述選項重疊或相輔相成。Other methods for updating Nano Server might overlap or complement the options above. 這些選項包括使用 WindowsServer Update Services (WSUS)、System Center Virtual Machine Manager (VMM)、工作排程器或非 Microsoft 的解決方案。Such options include using Windows Server Update Services (WSUS), System Center Virtual Machine Manager (VMM), Task Scheduler, or a non-Microsoft solution.