运行 VM 的 Shell 脚本

运行 VM 的 Shell 脚本

我使用 Virtualbox。我不想单击虚拟机名称的按钮来运行它,而是想要一个可以运行托管在 Ubuntu 机器上的 Windows XP 虚拟机的 shell 脚本。有人能帮我吗?

答案1

VBox_StopRestoreStart.sh

#!/bin/bash
if [ -z "$1" ]; then
        echo "Usage: $0 VMNAME_or_UUID"
        exit 1
fi
set -x
VBoxManage controlvm  "$1" poweroff  #enforce turnoff
VBoxManage snapshot   "$1" restorecurrent   #retore state
VBoxManage showvminfo "$1" | grep State   #display state to ensure
VBoxHeadless -s       "$1"  #run in headless mode in background

来源

相关内容