markdown
Windows 10 中使用 Hyper-V 架設虛擬機(Windows Server 2019),然後再虛擬機中再安裝 Hyper-V。
# Windows 10 宿主系統使用 Hyper-V,加一台 Windows Server 2019 的 Guest,再Guest系統中再安裝 Hyper-V。
## 環境
Host: Windows 10; 此篇文章後面簡稱 Win10
Guest: Windows Server 2019; 此篇文章後面簡稱 WinServer2019
已在 Hyper-V 中安裝好 Windows Server 2019 Standard 版本,虛擬機的名稱為 `win2019`

新增角色和功能

安裝角色為主的功能

選擇目前這台 Win2019 虛擬伺服器

找到 `Hyper-V` 勾選它

會詳細顯示要安裝的功能,按下「加入功能(Add Features)」

因為是在 win2019 裡面安裝 Hyper-V 時會出現錯誤,訊息如下:「Hyper-V cannot be installed: The processor does not have required virtualization capabilities.」,提示沒有辦法使用硬體支援虛擬化技術。

為了讓 Guest 虛擬機 win2019 能夠再安裝上 Hyper-V,需要在宿主系統啟用 ExposeVirtualizationExtensions 給 win2019 的虛擬機。
將 win2019 關機
回到宿主系統,以管理者權限開啟 powershell,會透過以下二行指令操作改變 ExposeVirtualizationExtensions 的設定值。
```text
Get-VMProcessor -VMName
| fl *
Set-VMProcessor -VMName -ExposeVirtualizationExtensions $true
```
我這裡的 Guest(Target VM's name) 名稱是 `win2019`
```
Get-VMProcessor -VMName win2019 | fl *
Set-VMProcessor -VMName win2019 -ExposeVirtualizationExtensions $true
```
執行 `Get-VMProcessor -VMName win2019 | fl *`,列出 win2019 虛擬機的設定,可以看到 ExposeVirtualizationExtensions 目前的狀態是 false
執行 `Set-VMProcessor -VMName win2019 -ExposeVirtualizationExtensions $true`,將 ExposeVirtualizationExtensions 啟用。
完成上述操作後,再次啟動 win2019 ,再加入 Hyper-V 的功能,即可將 Hyper-V 功能加入 win2019 虛擬機中。
## 資料參考
* [Creating Nested Hyper-V machines with Windows Server 2016 ](https://www.altaro.com/hyper-v/creating-nested-hyper-v-windows-server-2016/)
沒有留言:
張貼留言