HA

win10/11 家庭版中使用Hyper-V虚拟机

Tags:

开启Hyper-V

# 执行命令后重启
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause

将windows普通用户加入Hyper-V用户组中

如果不加的话就只能在管理员账户中使用Hyper-V 管理员模式打开powershell,执行下面命令

$loggedInUser =  (get-wmiobject  win32_computersystem).username
Add-LocalGroupMember -group "Hyper-V Administrators" -member $loggedInUser -ErrorAction SilentlyContinue

将vbox虚拟机实例转换为Hyper-V支持的vhd格式

VBoxManage.exe clonehd "D:\path\ubuntu20_0124-disk1.vdi" "D:\path\ubuntu22.vhd" --format VHD
# 转换完成后,在Hyper-V管理器中新建虚拟机时选择磁盘时选中已存在的vhd文件

连接到Hyper-V虚拟机中的服务

  1. ifconfig查看eth0的对应的ip
  2. 在宿主机上使用1中的ip进行连接即可

虚拟机和宿主机中共享文件夹

  1. 虚拟机中安装smaba sudo apt install samba
  2. 虚拟机中设置smb密码 sudo smbpasswd -a linux用户名
  3. 虚拟机中在想要共享的文件夹中的Properties中的Local Network Share中启用共享

调整虚拟机分辨率

set-vmvideo 虚拟机名 -horizontalresolution:1920 -verticalresolution:1080 -resolutiontype single

参考