Bài 06 · Chuyên đề Hyper-V

Tính năng nâng cao & Windows Server 2025

GPU passthrough/partitioning, SDN, affinity rules, Storage Replica, SCVMM, hotpatching... — những tính năng đưa Hyper-V ngang tầm VMware vSphere & Proxmox VE.

Về trang tổng Hyper-V

Đối chiếu Hyper-V ⇄ VMware vSphere ⇄ Proxmox VE

Hyper-V (đặc biệt từ Windows Server 2025) đã đạt ngang tầm hai nền tảng còn lại về tính năng cốt lõi. Bảng dưới đối chiếu chức năng tương đương:

Chức năngHyper-VVMware vSphereProxmox VE
Quản lý tập trungWAC + SCVMMvCenterPVE Web UI / Datacenter
HA clusterFailover ClusteringvSphere HAProxmox HA (corosync)
Di chuyển VM nóngLive MigrationvMotionLive Migration
Cân bằng tải tự độngDynamic Optimization (SCVMM)DRS(thủ công / script)
Affinity / Anti-affinityAntiAffinityClassNames + Preferred OwnerDRS rulesHA affinity rules
Lưu trữ HCIStorage Spaces Direct (S2D)vSANCeph
GPU ảo hoáDDA + GPU-P (live migrate WS2025)vGPU (NVIDIA GRID)PCIe passthrough / vGPU
SDN / micro-segmentationNetwork Controller (HNV)NSXSDN (zones/VNet)
Nhân bản DRHyper-V Replica + Storage ReplicavSphere ReplicationStorage/zfs replication
Sao chép khối site-to-siteStorage ReplicavSAN stretched / SRMCeph RBD mirror
Khử trùng lặp dữ liệuData Deduplication (ReFS)(vSAN dedup)ZFS dedup
Patch không rebootHotpatching (Azure Arc, WS2025)vSphere Lifecycle Mgr(live patch kernel)
Tự động hoáPowerShell / DSCPowerCLIAPI / pvesh / Ansible

Kết luận: với WAC (miễn phí) + tuỳ chọn SCVMM (có phí), Hyper-V phủ gần như toàn bộ tính năng enterprise của vSphere/Proxmox. Phần còn thiếu duy nhất so với vSphere là DRS tự động — bù bằng SCVMM Dynamic Optimization hoặc script.

GPU ảo hoá — DDA & GPU-P

  • DDA (Discrete Device Assignment): gán nguyên 1 GPU/thiết bị PCIe (NVMe, card mạng) cho 1 VM — hiệu năng gần bare-metal. Dùng cho AI/render. Tương đương PCIe passthrough.
  • GPU-P (GPU Partitioning): chia 1 GPU vật lý thành nhiều phần cho nhiều VM qua SR-IOV. Windows Server 2025 hỗ trợ live migration & HA cho VM có GPU-P. Tương đương NVIDIA vGPU.
# Liệt kê GPU hỗ trợ phân vùng + gán 1 phần cho VM (GPU-P) Get-VMHostPartitionableGpu Add-VMGpuPartitionAdapter -VMName VM-AI01 # DDA: gỡ thiết bị khỏi host rồi gán cho VM Dismount-VMHostAssignableDevice -LocationPath $path -Force Add-VMAssignableDevice -VMName VM-AI01 -LocationPath $path

Nested virtualization, SR-IOV & SDN

Nested Virtualization

Chạy Hyper-V/ESXi bên trong 1 VM — dựng lab cụm trên 1 máy. Set-VMProcessor -ExposeVirtualizationExtensions $true

SR-IOV

VM truy cập thẳng NIC vật lý — giảm độ trễ, bypass vSwitch. Bật khi tạo vSwitch -EnableIov $true

SDN — Network Controller

Mạng ảo hoá (HNV), micro-segmentation, software load balancer, gateway. Tương đương NSX. WS2025 thêm SDN multi-site.

WS2025: Network ATC (triển khai mạng theo "intent" tự động) + Network HUD (giám sát & tự sửa lỗi mạng) — đơn giản hoá cấu hình mạng cụm.

Provisioning hàng loạt & Affinity Rules

Template, Sysprep, Export/Import, Clone

# Chuẩn hoá 1 VM mẫu (Sysprep) rồi export làm template # Trong VM: C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /shutdown Export-VM -Name Template-WS2025 -Path "C:\ClusterStorage\Volume1\Templates" # Nhân bản VM mới từ template (import copy) Import-VM -Path "...\Template-WS2025\...vmcx" -Copy -GenerateNewId

Affinity / Anti-affinity (giống DRS rules)

Giữ các VM tránh nhau (anti-affinity, để HA không dồn cùng node) hoặc ở cùng node, và đặt node ưu tiên:

# Anti-affinity: 2 VM web không nằm cùng node (Get-ClusterGroup VM-Web01).AntiAffinityClassNames = "WebTier" (Get-ClusterGroup VM-Web02).AntiAffinityClassNames = "WebTier" # Node ưu tiên chạy VM (preferred owner) Set-ClusterOwnerNode -Group VM-Web01 -Owners H-NODE01,H-NODE02

Lưu trữ nâng cao

Storage Replica

Sao chép khối (block) đồng bộ/không đồng bộ giữa server/cụm/site — DR cấp ổ đĩa. New-SRPartnership

Data Deduplication

Khử trùng lặp trên ReFS/CSV — tiết kiệm dung lượng VM giống nhau. Enable-DedupVolume

Cluster Sets

Gộp nhiều cụm thành 1 "siêu cụm" — scale vượt 64 node, di chuyển VM giữa các cụm.

Hot-add, Automation & SCVMM

  • Hot-add: thêm RAM/vCPU/đĩa/NIC khi VM đang chạy (Gen2) — không downtime.
  • PowerShell Direct: chạy lệnh vào VM qua host, không cần mạng. Invoke-Command -VMName VM-Web01
  • DSC (Desired State Configuration): cấu hình VM theo trạng thái mong muốn, tự động hoá hạ tầng.
  • SCVMM (System Center Virtual Machine Manager — có phí): "vCenter đầy đủ" của Microsoft — quản lý fabric, template library, Dynamic Optimization (DRS-like), Power Optimization, bare-metal provisioning, quản lý đa cụm.

Azure Arc / Azure Local (Azure Stack HCI): đưa cụm Hyper-V lên quản lý lai từ Azure — giám sát, cập nhật, VM tự phục vụ, và hotpatching. Hướng hiện đại cho hạ tầng on-prem.

Điểm mới Windows Server 2025

Hiệu năng & GPU

  • GPU-P live migration & HA
  • Dynamic Processor Compatibility — trộn đời CPU, dùng tối đa feature chung
  • Live Migration nén dữ liệu, nhanh hơn

Vận hành & bảo mật

  • Workgroup / AD-less cluster (xác thực bằng certificate) — lý tưởng cho edge
  • Hotpatching qua Azure Arc — vá bảo mật không reboot
  • Network ATC / Network HUD · SMB over QUIC

🧪 LAB thực hành — Nested, Template & Anti-affinity

Mục tiêu: 3 bài chạy được ngay không cần phần cứng đặc biệt — bật nested cho VM-Lab01, biến nó thành template để nhân hàng loạt, và đặt anti-affinity cho 2 VM trên cụm.

1

Bật Nested Virtualization (VM phải tắt)

Stop-VM -Name VM-Lab01 Set-VMProcessor -VMName VM-Lab01 -ExposeVirtualizationExtensions $true Get-VMNetworkAdapter -VMName VM-Lab01 | Set-VMNetworkAdapter -MacAddressSpoofing On # → giờ có thể cài Hyper-V/ESXi BÊN TRONG VM-Lab01 để dựng lab cụm trên 1 máy

Cách GUI: Không có nút GUI cho nested virtualization — phải dùng PowerShell. Có thể bật MAC spoofing kèm theo tại Hyper-V Manager → VM Settings → Network Adapter → Advanced Features → "Enable MAC address spoofing".

2

Tạo template + nhân VM mới hàng loạt

# Trong VM: chạy Sysprep để tổng quát hoá rồi tắt máy # C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /shutdown Export-VM -Name VM-Lab01 -Path "D:\Templates" # Nhân 1 VM mới từ template (ID mới, file riêng) Import-VM -Path "D:\Templates\VM-Lab01\Virtual Machines\*.vmcx" -Copy -GenerateNewId

Cách GUI: Hyper-V Manager → chuột phải VM-Lab01 → Export… → chọn thư mục. Nhân bản: Action → Import Virtual Machine… → chọn thư mục export → "Copy the virtual machine (create a new unique ID)".

3

Anti-affinity: 2 VM web không nằm chung node (trên cụm)

(Get-ClusterGroup VM-Web01).AntiAffinityClassNames = "WebTier" (Get-ClusterGroup VM-Web02).AntiAffinityClassNames = "WebTier"

Cách GUI: Không có MMC riêng cho AntiAffinityClassNames (dùng PowerShell). Liên quan: Failover Cluster Manager → Roles → chuột phải VM → Properties → tab "Failover"/"General" để đặt Preferred Owners.

Kiểm chứng: Get-VMProcessor VM-Lab01 | fl ExposeVirtualizationExtensions = True; VM nhân bản hiện trong Get-VM; 2 VM web luôn nằm khác node sau khi failover.

GPU-P/DDA cần GPU hỗ trợ + driver phù hợp nên không đưa vào LAB chạy-ngay; xem lệnh tham khảo ở mục GPU ảo hoá phía trên.