设备换代,闲置一台 NUC 10。藉此学习搭设域控和 VDI。
Intel® NUC 10 Performance kit - NUC10i7FNH。产品介绍页 请见此
一些硬件信息:
使用 Windows Server 2022 评估版1)。宿主机安装 WS2022 后,只使用 Hyper-V 功能,用虚拟机搭设多台 WS2022 用作域控、远程桌面等。
Windows Server 2022 本身没有提供 NUC10 所需的有线网卡、无线网卡、声卡驱动,因此需要提前下载准备好驱动。
需要准备的有:
对于其他可能遗漏的驱动,可以在 设备管理器 –> 未识别的设备属性 –> 硬件ID 处找到设备号3),然后通过 Google 找到相应的驱动和解决方案 4)。
准备U盘,需要至少 8GB 空间。以下操作涉及磁盘分区操作,会清空U盘全部数据,重要数据请提前备份。
将在“前期准备”阶段下载好的 WS2022 ISO 移动到 C:\Temp\WindowsServer2022.iso 备用。打开 PowerShell,并运行下列命令5)。
# Define Path to the Windows Server 2022 ISO $ISOFile = "C:\Temp\WindowsServer2022.iso" # Create temp diectroy for new image $newImageDir = New-Item -Path 'C:\Temp\newimage' -ItemType Directory # Mount iso $ISOMounted = Mount-DiskImage -ImagePath $ISOFile -StorageType ISO -PassThru # Driver letter $ISODriveLetter = ($ISOMounted | Get-Volume).DriveLetter # Copy Files to temporary new image folder Copy-Item -Path ($ISODriveLetter +":\*") -Destination C:\Temp\newimage -Recurse # Split and copy install.wim (because of the filesize) dism /Split-Image /ImageFile:C:\Temp\newimage\sources\install.wim /SWMFile:C:\Temp\newimage\sources\install.swm /FileSize:4096 # Get the USB Drive you want to use, copy the disk number Get-Disk | Where BusType -eq "USB" # Get the right USB Drive (You will need to change the number) $USBDrive = Get-Disk | Where Number -eq 2 # Replace the Friendly Name to clean the USB Drive (THIS WILL REMOVE EVERYTHING) $USBDrive | Clear-Disk -RemoveData -Confirm:$true -PassThru # Convert Disk to GPT $USBDrive | Set-Disk -PartitionStyle GPT # Create partition primary and format to FAT32 $Volume = $USBDrive | New-Partition -Size 8GB -AssignDriveLetter | Format-Volume -FileSystem FAT32 -NewFileSystemLabel WS2022 # Copy Files to USB (Ignore install.wim) Copy-Item -Path C:\Temp\newimage\* -Destination ($Volume.DriveLetter + ":\") -Recurse -Exclude install.wim # Dismount ISO Dismount-DiskImage -ImagePath $ISOFile
系统安装过程从略。建议选择 Datacenter 版本,因为可以使用 inherited activation 激活虚拟机中的 WS2022。
安装好系统之后便可在 NUC10 中安装系统和驱动。只需要在设备管理器中依次更新硬件驱动即可(通过手动选择文件夹或者双击驱动安装程序)。
最后应该只剩下硬件ID为“BTHPAN”的设备,解决方式如下6):
宿主机不会创建域。因此配置过程较为简单。建议的操作如下:
之后便可在 Hyper-V 中创建虚拟机。利用 WS2022 映像,分别创建了3台虚拟机:
其中,RD VDI Host 虚拟机需要开启 Nested Virtualization9)10)。在 Powershell 中运行以下命令:
Stop-VM -Name <VMName>
Get-VM
Update-VMVersion -Name <VMName>
Set-VMProcessor -VMName <VMName> -ExposeVirtualizationExtensions $true
为了让第二层虚拟机可以接入网络,可以在第一层虚拟机的网卡上开启 MAC Address Spoofing11),操作如下(<VMname>处填写第一层虚拟机信息):
Get-VMNetworkAdapter -VMName <VMName> | Set-VMNetworkAdapter -MacAddressSpoofing On
微软官方文档提供的另外一种方式是 Nat networking,不过需要手动配置宿主机和各层网卡IP地址12)
Dism /online /Set-Edition:ServerDatacenter /AcceptEula /ProductKey:W3GNR-8DDXR-2TFRP-H8P33-DV9BG
,参考Automatic Virtual Machine Activation (AVMA)