虚拟机总结

1   VMware

2   VirtualBox

2.1   VirtualBox NAT网卡端口转发实现连接ssh

打开vbox虚拟机的设置->网络->高级->端口转发->新建规则:名称ssh,协议TCP,主机IP127.0.0.1,主机端口9191,子系统IP留空不填,子系统端口22。

2.2   VirtualBox安装ubuntu 18.04虚拟机打不开terminal终端

故障情况:VirtualBox新安装ubuntu 18.04虚拟机无法打开Terminal,从应用列表中单击Terminal,左上角任务栏会出现Terminal,并且鼠标转圈,但是过一会左上角Terminal消失,就像闪退一样。

解决方法:CTRL + ALT + F3 进入命令行模式(需要返回桌面时CTRL + ALT + F1)

1
2
3
4
5
cd /etc/default
sudo nano locale
# 把文件中的 “en_US” 改成 “en_US.UTF-8”
sudo locale-gen --purge
reboot #重启虚拟机

2.3   VirtualBox运行虚拟机系统卡顿/缓慢

可以观察下是否VirtualBox虚拟机底下状态栏是否出现了一个绿色海龟的图标,那证明当前VirtualBox运行在软件虚拟化模式,这确实会是十分缓慢的。而硬件虚拟化模式图标应该是蓝色的V。

问题原因:其他虚拟化技术软件启动hyper-v或者虚拟机平台功能引起,比如安装Docker Desktop开启wsl2功能后导致VirtualBox运行缓慢。

解决方法:

  1. 控制面板「程序和功能」中禁用Hyper-V和Windows hypervisor后重启系统(以下功能选项全部取消勾选)。如果仍然不行,cmd终端执行命令:bcdedit /set hypervisorlaunchtype off,执行完bcd命令后需要重启系统。
    • Containers
    • Hyper-V
    • Virtual Machine Platform
    • Windows Hypervisor Platform
    • Windows Sandbox
    • Windows Subsystem for Linux(WSL2是基于hyper-V架构的,但不是hyper-V本身)
  2. 移除并重装vbox增强工具包(VirtualBox Guest Additions)

2.4   VirtualBox无法删除备份

故障情况:删除备份时报错提示hard disk xxxx has more than one child hard disk 2。

解决方式:打开虚拟介质管理器,定位到虚拟硬盘页面,找到对应的硬盘,双击展开可以查看有一个子项目是不存在,失效导致删除备份失败,删除即可。

3   QEMU的相关资料

4   参考文献

[1] VirtualBox_Ubuntu22.04 Terminal 无法打开[EB/OL]. https://www.cnblogs.com/lifuqiang/articles/17167367.html.
[2] VirtualBox下SSH通过端口转发连接Linux方法[EB/OL]. https://blog.csdn.net/chengqiuming/article/details/83239413.
[3] [已解决] 为什么VBOX有些备份会删除失败?[EB/OL]. https://bbs.kafan.cn/thread-939721-1-1.html.
[4] FIX: VirtualBox Running Very Slow in Windows 10/11. (Solved)[EB/OL]. https://www.wintips.org/fix-virtualbox-running-very-slow-in-windows-10-11/.
[5] How to get VirtualBox 6.0 and WSL working at the same time [closed][EB/OL]. https://stackoverflow.com/questions/58031941/how‑to‑get‑virtualbox‑6‑0‑and‑wsl‑working‑at‑the‑same‑time.
[6] WSL2 breaks VirtualBox 6.1[EB/OL]. https://github.com/MicrosoftDocs/WSL/issues/798.