Tạo máy ảo trên powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# confirm network adapter names
PS C:\Users\Administrator> Get-NetAdapter
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
Ethernet0 Intel(R) 82574L Gigabit Network Conn... 6 Up 00-0C-29-C7-54-1A 1 Gbps
# create a virtul switch
PS C:\Users\Administrator> New-VMSwitch -Name "Bridge01" -AllowManagementOS $True -NetAdapterName "Ethernet0"
# confirm
PS C:\Users\Administrator> Get-VMSwitch
Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
Bridge01 External Intel(R) 82574L Gigabit Network Connection
# create a directory for virtual machines
PS C:\Users\Administrator> mkdir E:\Virtual_Machine
# set VM name and others
PS C:\Users\Administrator> $ParentDir = 'E:\Virtual_Machine'
PS C:\Users\Administrator> $VMName = 'CentOS8'
PS C:\Users\Administrator> $Switch = 'Bridge01'
# create a virtual machine
PS C:\Users\Administrator> New-VM -Name $VMName `
-MemoryStartupBytes 4GB `
-Generation 1 `
-NewVHDPath "$ParentDir\$VMName\$VMName.vhdx" `
-NewVHDSizeBytes 20GB `
-Path "$ParentDir\$VMName" `
-SwitchName $Switch
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
CentOS8 Off 0 0 00:00:00 Operating normally 9.0
# change vCPU count
PS C:\Users\Administrator> Set-VMProcessor $VMName -Count 2
# confirm virtual DVD drive
PS C:\Users\Administrator> Get-VMDvdDrive -VMName $VMName
VMName ControllerType ControllerNumber ControllerLocation DvdMediaType Path
------ -------------- ---------------- ------------------ ------------ ----
CentOS8 IDE 1 0 None
# set install image to virtual DVD drive
PS C:\Users\Administrator> Set-VMDvdDrive -VMName $VMName `
-Path 'C:\Users\Administrator\Documents\CentOS-8.2.2004-x86_64-dvd1.iso'
PS C:\Users\Administrator> Get-VMDvdDrive -VMName $VMName
VMName ControllerType ControllerNumber ControllerLocation DvdMediaType Path
------ -------------- ---------------- ------------------ ------------ ----
CentOS8 IDE 1 0 ISO C:\Users\Administrator\Documents\CentOS-8.2.2004-x86...
# start the virtual machine
PS C:\Users\Administrator> Start-VM -Name $VMName
# after this, refer to [13] to install OS
Tạo máy ảo trên GUI
Mở Server Manager và chọn Tools- Hyper-V Manager

Nhấn chuột phải vào máy chủ tạo máy ảo chọn New-New Machine…

Chọn Next

Tiếp theo, đặt tên cho máy ảo

Chọn thế hệ cho máy ảo

tiếp theo, gán bộ nhớ cho máy ảo

Chọn virtual switch để sử dụng kết nối cho máy ảo

Tiếp theo, chọn dung lượng ổ đĩa ảo, tùy vào mục đích sử dụng bạn có thể lựa chọn dung lượng

tiếp theo, chọn đường dẫn cài đặt GuestOS của máy ảo

Sau khi cấu hình xong, nếu không có vấn đề gì, chọn Finish để tạo máy ảo

Để bật máy ảo, nhấn chuột phải vào máy áo, chọn Start

Để kết nối đến bảng điều khiển của máy ảo, nhấp chuột phải vào máy ảo chọn Connect…

sau đó, ta tiến hành cài đặt CentOS 7 như bình thường

Quá trình tạo máy ảo CentOS 7 đã hoàn thành.
