关闭在无头 VirtualBox 中运行的 Ubuntu 服务器

Oxw*_*ivi 16 server virtualbox

我正在使用VBoxHeadless. 如何通过 VirtualBox 发送 ACPI 关闭信号并使 Ubuntu Server 尊重它并遵守关闭信号?

Tak*_*kat 23

如果要关闭来宾 Ubuntu,您有两个选择:

使用 VBoxManage 关闭访客

可以使用VBoxManage命令行工具通过命令行控制虚拟机:

VBoxManage controlvm [nameofmachine] savestate       # saves the state of the VM like in suspend
VBoxManage controlvm [nameofmachine] poweroff        # simply "unplugs" the VM
VBoxManage controlvm [nameofmachine] acpipowerbutton # sends ACPI poweroff signal
Run Code Online (Sandbox Code Playgroud)

为了通过 ACPI 关闭电源,虚拟操作系统需要能够这样做,VirtualBox 可能还需要为 VM 启用 ACPI 支持。

  • 启用 VirtualBox ACPI 选项:

    VBoxManage modifyvm [nameofmachine] --acpi on
  • 在 Ubuntu VM 中安装 ACPI 支持:

    sudo apt-get install acpid

从 SSH 关闭来宾

一种更安全的关闭机器的方法,以防您有 SSH 访问权限

user@virtualmachine: sudo poweroff
Run Code Online (Sandbox Code Playgroud)

这将注意安全关闭和关闭您的来宾操作系统。