「VirtualBox」- Guest OS

从命令行中,管理虚拟机

How to run VirtualBox virtual machines from the command line

# VBoxManage startvm "Ubuntu Server" --type headless

自动补全(Bash):gryf/vboxmanage-bash-completion: VBoxManage bash completion

远程管理虚拟机

关键技术:RemoteBox、vboxwebsrv

RemoteBox : News | RemoteBox – ArchWiki | RemoteBox : Downloads
How to set up a VirtualBox remote GUI for easy VM management | TechRepublic

前端界面

#13308 (GUI Always Start Headless) – Oracle VM VirtualBox
7.1.2. VBoxHeadless, the Remote Desktop Server
8.12. VBoxManage startvm

启动虚拟机的三种方式:
1)gui(显示用于访问虚拟机的窗口),Starts a VM showing a GUI window. This is the default.
2)headless(后台运行),Starts a VM without a window for remote display only.
3)separate(gui + headless,两者是独立进程),Starts a VM with a detachable UI. Technically, it is a headless VM with user interface in a separate process. This is an experimental feature as it lacks certain functionality, such as 3D acceleration.

# 设置虚拟机默认无界面启动,后台运行
VBoxManage modifyvm "vmname" --defaultfrontend headless

# 设置全局默认无界面启动
VBoxManage setproperty defaultfrontend headless

# 针对我们的应用场景,我们的使用方式:
# 1)我们更倾向于默认全局 headless 启动(我们并不依赖 3D 加速);
# 2)然后,为虚拟机配置 Remote Desktop 显示,并通过 Remmia 来连接;

# 08/10/2022 到目前为止(我们使用 VirtualBox 6.1.32 版本),除了 GUI 方式外,其他两种模式无法进行 3D 加速,所以视频播放会导致 CPU 使用较高。

虚拟机克隆(Clone)

Clone the virtual machine in the Oracle VM VirtualBox – Appuals.com

1)关闭虚拟机实例;

2)右键 “Clone” 按钮;
3)根据提示填写参数,并确认;

USB Passthrought

Writing a Simple Linux Kernel Module | by Robert W. Oliver II | Sourcerer Blog

# 将用户(这里是 virtmgr 用户)添加到 vboxusers 组中;
usermod --append -G vboxusers virtmgr

# 退出重新登录,或者重启系统 

… create a proxy device for the usb device. (error verr_pdm_no_usb_ports) …

How to solve VirtualBox exception when attaching a USB device: …

在虚拟机设置中,修改 USB 配置,选择 USB 3.0 (xHCI) Controller 选项;

Mouse Integration

virtualbox – Centos 7 Mouse integration on Virtual Box not working
如果使用触控板来进行操作,鉴于其并非 USB 设备,需要 <VM> / System / Pointing Device / PS/2 Mouse 配置;

禁用 Guest 对 Host 电池信息的感知

Report Battery Information in the Guest
virtualbox.org/How to make guest unaware of battery power source?
virtualbox.org/Running from mains not battery
virtualbox.org/Disable Guest battery state api

问题描述:我们在笔记本中,运行 VirtualBox 虚拟机,但是我们不希望 Host 向 Guest 汇报电池状态;

在 VMware Workstatin 中,通过如下设置:
Select the virtual machine and select VM > Settings.
On the Options tab, select Power.
Select Report battery information to guest.
Click OK to save your changes.

在 Virtualbox 中,我们暂时没有找到相关配置。

官方文档与电池相关的描述(1.3. Features Overview):

Full ACPI support. The Advanced Configuration and Power Interface (ACPI) is fully supported by Oracle VM VirtualBox. This enables easy cloning of disk images from real machines or third-party virtual machines into Oracle VM VirtualBox. With its unique ACPI power status support, Oracle VM VirtualBox can even report to ACPI-aware guest OSes the power status of the host. For mobile systems running on battery, the guest can thus enable energy saving and notify the user of the remaining power, for example in full screen modes.