Virtual Box
Dionysen

VirtualBox创建虚拟机,如果不开启硬件虚拟化,性能很差,但要开启,需要将所有其他软件Hyper-V的占用终止。

参考链接:
https://forums.virtualbox.org/viewtopic.php?f=1&t=62339
https://blog.csdn.net/lingzhentaor/article/details/147710636

Windows功能关闭

必要要关闭的是:

手动关闭Hyper-V

以管理员权限启动PowerShell,执行命令:

bcdedit /set hypervisorlaunchtype off

然后重启。

VBS

如果上面全部关闭后依然无法启用硬件虚拟化,使用 win+r 打开 msinfo32 ,查看“基于虚拟化的安全性”(VBS)是否为启用状态,如果启用,要使用windows的dgreadiness工具来关闭。

  1. 下载dgreadiness
  2. 解压到特定目录
  3. 以管理员权限启动PowerShell,进入解压的目录: cd C:/dgreadiness
  4. 使用命令关闭VBS: ./DG_Readiness_Tool_v3.6.ps1 -Disable -AutoReboot
  5. 然后计算机会自动重启,启动时可能需要按 win 或 F3 确认关闭VBS

重启之后再次检查VSB功能是否关闭。

硬件虚拟化设置灰显

找到VirtualBox的安装目录,在目录中执行命令:

./VBoxManage.exe list vms
./VBoxManage.exe modifyvm "KylinOS" --nested-hw-virt on

远程连接VirtualBox中的虚拟机

虚拟机中安装SSH服务

# 安装 OpenSSH Server
sudo apt update && sudo apt install -y openssh-server

# 启动并设置开机自启
sudo systemctl enable --now ssh

VirtualBox中设置端口转发

比如22 → 2222 .

宿主机测试

ssh -p 2222 username@127.0.0.1

虚拟机使用宿主机的代理

虚拟机设置

  • 虚拟设置中将网络改为NAT。

在虚拟机中设置代理

先查看ip:

➜  ~ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fd00::ec59:4545:8ac4:d3df prefixlen 64 scopeid 0x0<global>
inet6 fd00::e450:a2ab:1c0d:ae6f prefixlen 64 scopeid 0x0<global>
inet6 fe80::26e9:ae7f:a430:c784 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:d2:b5:54 txqueuelen 1000 (Ethernet)
RX packets 244620 bytes 223506448 (223.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 146175 bytes 19006259 (19.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 10321 bytes 2209770 (2.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10321 bytes 2209770 (2.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

然后在.bashrc或.zshrc(取决于你使用什么shell)中添加:

alias set-proxy='export http_proxy="http://10.0.2.2:7890" export https_proxy="http://10.0.2.2:7890" export all_proxy="socks5://10.0.2.2:7890"'

其中代理设置为虚拟机的地址:宿主机代理的端口。

后续使用set-proxy开启代理。

虚拟机与宿主机通过alt+tab切换

全局设定 -> 热键 -> 扩展特性。

  • 关闭自动独占键盘即可。
显示评论