Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 7 VHD 原生開機完整部署指南:從建立 VHD 到多重開機選單

編輯:Win7 常見問題解答

Windows 7 Enterprise/Ultimate 及 Windows Server 2008 R2 引入 VHD Native Boot,讓作業系統能直接從虛擬硬碟檔(.vhd)開機,無需傳統分區。本文整理官方技術文件與實戰經驗,提供完整指令級部署流程。

支援版本與硬體限制

項目需求
客戶端版本Windows 7 Enterprise / Ultimate
伺服器版本Windows Server 2008 R2(Foundation 除外)
磁碟分區至少兩個分區:System 分區(含 Bootmgr、BCD)+ 資料分區(存放 VHD)
VHD 類型建議固定大小;動態擴充需確保實體空間足夠
掛載上限最多 512 個 VHD
不支援功能休眠、SMB 共享開機、BitLocker 加密 VHD 所在卷、VHD 做動態磁盤/軟體 RAID
效能特性讀取接近實體硬碟;寫入無 Cache,稍慢於實體

必備工具箱

  • bcdboot.exe:建立/修復開機檔案與 BCD 存放區
  • bcdedit.exe:編輯開機配置資料
  • diskpart.exe:建立、掛載、分區、格式化 VHD
  • imagex.exe:釋放 WIM 安裝映像到 VHD(Windows AIK/ADK 內含)
  • Windows Deployment Services (WDS):選用,網路部署用

核心指令速查

# 建立 10GB 固定大小 VHD
create vdisk file=E:\Win7.vhd maximum=10000 type=fixed

# 選取並掛載
select vdisk file=E:\Win7.vhd
attach vdisk

# 建立主分區、指派磁碟代號、快速格式化
create partition primary
assign letter=R
format quick fs=ntfs

# 釋放安裝映像(假設 WIM 索引 1 為 Enterprise)
imagex /apply D:\sources\install.wim 1 R:\

# 寫入開機檔案到系統分區(假設系統分區為 S:)
bcdboot R:\Windows /s S: /l zh-TW

# 在 BCD 中新增開機項目(需先取得 {GUID})
bcdedit /copy {current} /d "Windows 7 VHD Boot"
bcdedit /set {new_guid} device vhd=[E:]\Win7.vhd
bcdedit /set {new_guid} osdevice vhd=[E:]\Win7.vhd
bcdedit /displayorder {new_guid} /addlast

兩種部署情境

情境 A:現有 OS 電腦上新增 VHD 開機項目

  1. 以管理員身分開啟 CMD,執行上述 diskpart 建立/掛載 VHD。
  2. 用 imagex 釋放 install.wim 到 VHD 磁碟機(如 R:)。
  3. 執行 bcdboot R:\Windows 更新本機 BCD(會自動新增開機項目)。
  4. 重開機選單即出現新項目。

情境 B:裸機部署(無預裝 OS)

  1. 用 WinPE/安裝光碟開機,進入 Shift+F10 命令提示字元。
  2. diskpart 建立 系統分區(100-350MB,NTFS,標示為作用中) 與 資料分區。
  3. 在資料分區建立 VHD 並掛載。
  4. imagex 釋放映像到 VHD。
  5. bcdboot VHD磁碟機:\Windows /s 系統分區磁碟機: /l zh-TW 寫入開機檔。
  6. 重開機即可從 VHD 進入 Windows。

進階應用:差異 VHD 做測試環境

# 建立父 VHD(已裝好基礎環境)
create vdisk file=E:\Base.vhd maximum=20000 type=fixed
# ... 安裝完成並 Sysprep 封裝 ...

# 建立子 VHD(差異磁碟),所有寫入導向子 VHD,父 VHD 保持唯讀
create vdisk file=E:\Test1.vhd parent=E:\Base.vhd type=differencing
# 掛載 Test1.vhd 並加入 BCD,即可擁有乾淨、可還原的測試環境
⚠ 注意事項:
1. VHD 檔案一旦損毀,整個系統掛點。務必定期備份 .vhd 檔。
2. 動態 VHD 若實體磁碟爆滿,系統會當機並損毀資料。生產環境請用固定大小。
3. 修改 BCD 前請先 bcdedit /export backup.bcd 備份。

掌握 VHD Native Boot,不僅能輕鬆管理多版本測試環境,還能將整個作業系統當作可攜式檔案帶著走。對開發、測試、教學場景極具價值。

Copyright © Windows教程網 All Rights Reserved