cap*_*gon 17 startup virtualbox
我似乎无法让我的 VM 在启动时运行。
我尝试了“启动应用程序”和 update-rc.d 没有运气。
sudo update-rc.d startvms defaults 99 10
Run Code Online (Sandbox Code Playgroud)
这为不同的运行级别创建了所有适当的符号链接,但 VM 仍未启动。
这是我的 startvms 脚本:
#!/bin/bash
### BEGIN INIT INFO
# Provides: startvms
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start my VMs at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
case "$1" in
start)
echo "Starting"
nohup VBoxHeadless --startvm "UbuntuServer" &
;;
stop)
echo "Stopping $DESC"
VBoxManage controlvm "UbuntuServer" poweroff
;;
restart|force-reload)
echo "Restarting $DESC"
VBoxManage controlvm "UbuntuServer" poweroff
nohup VBoxHeadless --startvm "UbuntuServer" &
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
cap*_*gon 27
这 就是最终奏效的方法!
在 /etc/init.d - 中sudo nano /etc/init.d/StartVM。
将以下内容粘贴到文件中,并将“我的虚拟机名称”替换为您的虚拟机名称:
#! /bin/sh
# /etc/init.d/StartVM
#
#Edit these variables!
VMUSER=spode
VMNAME="My VM Name"
case "$1" in
start)
echo "Starting VirtualBox VM..."
sudo -H -b -u $VMUSER /usr/bin/VBoxVRDP -s "$VMNAME"
;;
stop)
echo "Saving state of Virtualbox VM..."
sudo -H -u $VMUSER /usr/bin/VBoxManage controlvm "$VMNAME" savestate
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0
Run Code Online (Sandbox Code Playgroud)
与sudo chmod +x /etc/init.d/StartVM.
告诉脚本第一个关闭,最后一个启动。
sudo update-rc.d StartVM defaults 99 01
| 归档时间: |
|
| 查看次数: |
59119 次 |
| 最近记录: |