開機至虛擬硬碟:將 VHDX 或 VHD 新增至開機功能表Boot to a virtual hard disk: Add a VHDX or VHD to the boot menu

原生開機可讓您建立 (VHDX) 的虛擬硬碟、將 Windows 安裝到該磁片,然後在您的電腦上與現有的安裝並存或在新裝置上開機。Native Boot allows you to create a virtual hard disk (VHDX), install Windows to it, and then boot it up, either on your PC side-by-side with your existing installation, or on a new device.

原生開機 VHDX 可以用來做為指定硬體上執行的作業系統,而不需要任何其他父系作業系統。A native-boot VHDX can be used as the running operating system on designated hardware without any other parent operating system. 這不同于在具有父系作業系統的電腦上,將 VHDX 連接到虛擬機器的情況。This differs from a scenario where a VHDX is connected to a virtual machine on a computer that has a parent operating system.

Windows 10 的原生開機需要 .vhdx 格式,而不是 .vhd 格式。Native boot for Windows 10 requires the .vhdx format, not the .vhd format.

Vhdx 可套用至沒有任何其他 Windows 安裝的電腦或裝置,而不需要虛擬機器或虛擬程式。VHDXs can be applied to PCs or devices that have no other installations of Windows, without a virtual machine or hypervisor. (的執行程式是在執行虛擬電腦的作業系統下的一層軟體。 ) 這可在工作負載散發中提供更大的彈性,因為您可以使用一組工具來管理虛擬機器和指定硬體的映射。(A hypervisor is a layer of software under the operating system that runs virtual computers.) This enables greater flexibility in workload distribution because a single set of tools can be used to manage images for virtual machines and designated hardware.

您也可以將 VHDX 部署到已安裝 Windows 的電腦上,並使用開機功能表來選取現有的 Windows 版本,或 VHD 上的版本。You can also deploy the VHDX to a PC that already has Windows installed on it, and use a boot menu to select between the existing version of Windows, or the version on the VHD.

若要深入瞭解如何在企業環境中使用 Vhdx,請參閱 瞭解具有原生開機的虛擬硬碟To learn more about using VHDXs in an enterprise environment, see Understanding Virtual Hard Disks with Native Boot.

必要條件Prerequisites

  • 已安裝 windows ADK) 工具 (windows 評定及部署套件的技術人員電腦。A technician PC with the Windows Assessment and Deployment Kit (Windows ADK) tools installed on it.

  • ( 的一般化 Windows 映像。) 的 WIM 檔案。A generalized Windows image (.WIM file). 若要深入瞭解,請參閱 Sysprep (一般化) Windows 安裝To learn more, see Sysprep (Generalize) a Windows installation.

  • 可開機的 Windows PE 磁片磁碟機。A bootable Windows PE drive. 若要深入瞭解,請參閱 WinPE:建立 USB 可開機磁片磁碟機To learn more, see WinPE: Create USB Bootable drive.

  • 要在其上安裝 VHDX 的目的地電腦或裝置。A destination PC or device on which to install the VHDX. 此裝置需要 30 gb 的 (GB) 或更多的可用磁碟空間。This device requires 30 gigabytes (GB) or more of free disk space. 您可以將 VHDX 安裝到已執行其他作業系統安裝的裝置,或安裝在裝置上的唯一作業系統。You can install the VHDX to a device already running other operating system installations, or as the only operating system on a device.

步驟1:從 diskpart 建立 VHDXStep 1: Create a VHDX from diskpart

在技術人員電腦上:On the technician PC:

  1. 從命令提示字元開啟 Diskpart。From the Command Prompt, open Diskpart.

    diskpart
    
  2. 建立並準備新的 VHDX。Create and prepare a new VHDX. 在此範例中,我們會建立 25 GB 的固定類型 VHDX。In this example, we create a 25 GB fixed-type VHDX.

    create vdisk file=C:\windows.vhdx maximum=25600 type=fixed
    
  3. 附加 VHDX。Attach the VHDX. 這會將 VHDX 以磁片的形式新增至主機上的存放控制器。This adds the VHDX as a disk to the storage controller on the host.

    attach vdisk
    
  4. 建立 Windows 檔案的磁碟分割、將其格式化,並為其指派磁碟機號。Create a partition for the Windows files, format it, and assign it a drive letter. 此磁碟機號將會出現在檔案總管中。This drive letter will appear in File Explorer.

    create partition primary
    format quick label=vhdx
    assign letter=v
    
  5. Exit DiskpartExit Diskpart

    exit
    

步驟2:將 Windows 映像套用至 VHDStep 2: Apply a Windows image to the VHD

在您的技術人員電腦上,將一般化的 Windows 映像套用至您在 步驟 1中建立並附加之 VHDX 的主要磁碟分割。On your technician PC, apply a generalized Windows image to the primary partition of the VHDX that you created and attached in Step 1.

Dism /Apply-Image /ImageFile:install.wim /index:1 /ApplyDir:V:\

步驟3:卸離 VHD、將它複製到新裝置,然後將它附加 (選用) Step 3: Detach the VHD, copy it to a new device, and attach it (optional)

您可以將 VHDX 部署到已安裝 Windows 複本的裝置上,也可以清除並準備目的地電腦的硬碟以使用 VHD。You can deploy the VHDX to a device that already has a copy of Windows installed on it, or you can clean and prepare the destination PC's hard drive to use the VHD.

將 VHDX 卸離,並將其儲存到網路共用或存放磁片磁碟機Detach the VHDX and save it to a network share or storage drive

  1. 使用 diskpart 從技術人員電腦卸離虛擬磁片。Use diskpart to detach the virtual disk from your technician PC.

    diskpart
    select vdisk file=C:\windows.vhdx
    detach vdisk
    exit
    
  2. 將 VHDX 複製到網路共用或卸除式存放裝置磁片磁碟機。Copy the VHDX to a network share or removable storage drive. 以下會將磁碟機號對應至網路共用、建立 VHD 的目錄,然後複製 VHD。The following maps a drive letter to a network share, creates a directory for the VHD, and then copies the VHD.

    net use n: \\server\share\
    md N:\VHDs
    copy C:\windows.VHDX n:\VHDs\
    

清除並準備新的裝置以進行原生開機Clean and prepare a new device for native boot

在您的目的地電腦上:On your destination PC:

  1. 使用可開機的 WinPE 金鑰,將 目的地電腦開機至 WinPEUse your bootable WinPE key to boot the destination PC to WinPE.

  2. 清除並準備目的地電腦的硬碟。Clean and prepare the destination PC's hard drive. 建立系統磁碟分割 (S) ,以及將儲存 VHDX 的主要磁碟分割 (M) 。Create a system partition (S), and a main partition (M) where the VHDX will be stored.

    BIOS:BIOS:

    diskpart
    select disk 0
    clean
    rem == 1. System partition ======================
    create partition primary size=100
    format quick fs=ntfs label="System"
    assign letter="S"
    active
    rem == 2. Main partition ========================
    create partition primary
    format quick fs=ntfs label="Main"
    assign letter="M"
    exit
    

    UEFIUEFI:

    diskpart
    select disk 0
    clean
    convert gpt
    rem == 1. System partition =========================
    create partition efi size=100
    format quick fs=fat32 label="System"
    assign letter="S"
    rem == 2. Microsoft Reserved (MSR) partition =======
    create partition msr size=128
    rem == 3. Main partition ===========================
    create partition primary 
    format quick fs=ntfs label="Main"
    assign letter="M"
    exit
    
  3. 連接至您在 步驟 3.2中複製 VHDX 的網路磁碟機機或儲存位置。Connect to the network drive or storage location where you copied the VHDX in step 3.2.

    net use N: \\server\share
    
  4. 將 VHDX 從網路磁碟機機或儲存位置複製到目的地電腦的主要磁碟分割。Copy the VHDX from the network drive or storage location to the destination PC's main partition.

    copy N:\VHDs\Windows.vhdx M:
    

附加 VHDXAttach the VHDX

  1. 在仍開機至 WinPE 的情況下,請將您的 VHDX 連接到目的地電腦。While still booted into WinPE, attach your VHDX to the destination PC.

    diskpart
    select vdisk file=M:\windows.vhdx
    attach vdisk
    
  2. 識別附加的 VHDX 的磁片區信件。Identify the attached VHDX's volume letter. (選擇性:將它變更為另一個更有意義的字母(例如 V),並讓 diskpart 命令列保持開啟,以供下一個步驟) 。(Optional: Change it to another letter that makes more sense, for example V, and leave the diskpart command line open for the next step).

    list volume
    select volume 3
    assign letter=v
    

步驟4:新增開機專案Step 4: Add a boot entry

  1. 在您的目的地電腦上,視需要開啟 Diskpart () ,並找出 VHDX 和系統磁碟分割的磁碟機號,例如 V 和 S。From your destination PC, open Diskpart (if necessary) and identify the drive letters of the VHDX and the system partition, for example, V and S.

    diskpart
    list volume
    exit
    
  2. 將開機專案新增至裝置。Add a boot entry to the device. 您可以使用這個方法來新增多個 VHDX 檔案。You can add multiple VHDX files using this method.

    BIOS:BIOS:

    V:
    cd v:\windows\system32
    bcdboot v:\windows /s S: /f BIOS
    

    UEFIUEFI:

    V:\
    cd v:\windows\system32
    bcdboot v:\windows /s S: /f UEFI
    
  3. 移除 Windows PE USB 金鑰。Remove the Windows PE USB key.

  4. 重新開機目的地電腦。Restart the destination PC.

    如果只有一個開機專案,裝置會立即啟動至 Windows。If there's only one boot entry, the device immediately boots to Windows. 如果有一個以上的開機專案,您會看到開機功能表,讓您可以在裝置上的可用 Windows 版本之間進行選擇。If there's more than one boot entry, you'll see a boot menu where you can choose between the available versions of Windows on the device.

相關主題Related topics

瞭解具有原生開機的虛擬硬碟Understanding Virtual Hard Disks with Native Boot

BCDboot Command-Line 選項BCDboot Command-Line Options