Homelab Setup
设备换代,闲置一台 NUC 10。藉此学习搭设域控和 VDI。
前期准备
硬件
Intel® NUC 10 Performance kit - NUC10i7FNH。产品介绍页 请见此
一些硬件信息:
系统
使用 Windows Server 2022 评估版1)。宿主机安装 WS2022 后,只使用 Hyper-V 功能,用虚拟机搭设多台 WS2022 用作域控、远程桌面等。
驱动
Windows Server 2022 本身没有提供 NUC10 所需的有线网卡、无线网卡、声卡驱动,因此需要提前下载准备好驱动。
需要准备的有:
- 有线网卡 Intel Ethernet Connection I219 驱动:Intel® Ethernet Adapter Complete Driver Pack - 子目录 PRO1000\Winx64\WS2022 可提供有线网卡 Intel Ethernet Connection I219-LM 的驱动2)。
- 无线网卡 Intel® Wi-Fi 6 AX201 驱动:Intel® PROSet/Wireless Software and Drivers for IT Admins version 22.130.0
- 显卡驱动:Intel® Graphics DCH Driver for Intel® NUC,系统自带的也能用,但是有可以用的厂商驱动何乐不为 XD。
- 其他:INF driver packs for Intel® NUC Kit NUC10i7FNx for Windows® 10, 64-bit - 全部 INF 驱动,用于一些零散的、未识别硬件。
对于其他可能遗漏的驱动,可以在 设备管理器 –> 未识别的设备属性 –> 硬件ID 处找到设备号3),然后通过 Google 找到相应的驱动和解决方案 4)。
操作步骤
创建启动 U 盘
准备U盘,需要至少 8GB 空间。以下操作涉及磁盘分区操作,会清空U盘全部数据,重要数据请提前备份。
将在“前期准备”阶段下载好的 WS2022 ISO 移动到 C:\Temp\WindowsServer2022.iso 备用。打开 PowerShell,并运行下列命令5)。
- create-usb.ps
# 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):
- 在设备管理器中定位到硬件ID为BTH\MS_BTHPAN的设备,点击更新驱动;
- 点击Let me pick from a list of available drivers on my computer > Bluetooth;
- 左侧制造商选择 Microsoft,右侧选择 Personal Area Network Service 即可。
配置 Windows Server
宿主机不会创建域。因此配置过程较为简单。建议的操作如下:
- 修改计算机名;
- 添加角色 Hyper-V;
之后便可在 Hyper-V 中创建虚拟机。利用 WS2022 映像,分别创建了3台虚拟机:
- Domain Controller (1vCPU/512MB)。修改计算机名,更新系统,激活7),创建域(根据戴有炜:《配置Windows Server 2016系统配置指南》配置),并新建组织和用户;
- RDS License Host (1vCPU/512MB)。修改计算机名,更新系统,激活,加入域,创建角色并配置RDS授权(操作步骤施工中)
- RD VDI Host (4vCPU/16GB)。修改计算机名,更新系统,激活,加入域名,创建角色(操作步骤施工中)8)
其中,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)