Autostart Virtual Machine VBoxHeadless at boot with Upstart - init and Graceful exit
I want to automatically start a VirtualBox Virtual Machine at boot on a Ubuntu 14 Linux Headless Server.
I have tried @reboot
via crontab, but the VboxHeadless
command does not seem to work in conjunction with @reboot
. I think its a timing issue.
So I have researched more and was guided to make a Upstart Script. How can I go about this?
virtualbox sysvinit upstart
add a comment |
I want to automatically start a VirtualBox Virtual Machine at boot on a Ubuntu 14 Linux Headless Server.
I have tried @reboot
via crontab, but the VboxHeadless
command does not seem to work in conjunction with @reboot
. I think its a timing issue.
So I have researched more and was guided to make a Upstart Script. How can I go about this?
virtualbox sysvinit upstart
@reboot trail and error and failing post just for reference
– FreeSoftwareServers
Oct 24 '15 at 2:41
add a comment |
I want to automatically start a VirtualBox Virtual Machine at boot on a Ubuntu 14 Linux Headless Server.
I have tried @reboot
via crontab, but the VboxHeadless
command does not seem to work in conjunction with @reboot
. I think its a timing issue.
So I have researched more and was guided to make a Upstart Script. How can I go about this?
virtualbox sysvinit upstart
I want to automatically start a VirtualBox Virtual Machine at boot on a Ubuntu 14 Linux Headless Server.
I have tried @reboot
via crontab, but the VboxHeadless
command does not seem to work in conjunction with @reboot
. I think its a timing issue.
So I have researched more and was guided to make a Upstart Script. How can I go about this?
virtualbox sysvinit upstart
virtualbox sysvinit upstart
edited 51 secs ago
asked Oct 24 '15 at 2:36
FreeSoftwareServers
98331836
98331836
@reboot trail and error and failing post just for reference
– FreeSoftwareServers
Oct 24 '15 at 2:41
add a comment |
@reboot trail and error and failing post just for reference
– FreeSoftwareServers
Oct 24 '15 at 2:41
@reboot trail and error and failing post just for reference
– FreeSoftwareServers
Oct 24 '15 at 2:41
@reboot trail and error and failing post just for reference
– FreeSoftwareServers
Oct 24 '15 at 2:41
add a comment |
1 Answer
1
active
oldest
votes
Create Script >> Make it executable >> "Install" script via update-rc.d
cat << 'EOL' >/etc/init.d/StartVM
#!/bin/sh
#Edit these variables!
VMUSER=user
VMNAME=VM1
VMNAME2=Test
case "$1" in
start)
echo "Starting VirtualBox VM ..."
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME &
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME2 &
;;
stop)
echo "Saving state of Virtualbox VM ..."
sudo -u $VMUSER VBoxManage controlvm $VMNAME savestate
sudo -u $VMUSER VBoxManage controlvm $VMNAME2 acpipowerbutton
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0
EOL
sudo chmod +x /etc/init.d/StartVM
sudo update-rc.d StartVM defaults
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f238287%2fautostart-virtual-machine-vboxheadless-at-boot-with-upstart-init-and-graceful%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Create Script >> Make it executable >> "Install" script via update-rc.d
cat << 'EOL' >/etc/init.d/StartVM
#!/bin/sh
#Edit these variables!
VMUSER=user
VMNAME=VM1
VMNAME2=Test
case "$1" in
start)
echo "Starting VirtualBox VM ..."
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME &
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME2 &
;;
stop)
echo "Saving state of Virtualbox VM ..."
sudo -u $VMUSER VBoxManage controlvm $VMNAME savestate
sudo -u $VMUSER VBoxManage controlvm $VMNAME2 acpipowerbutton
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0
EOL
sudo chmod +x /etc/init.d/StartVM
sudo update-rc.d StartVM defaults
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
add a comment |
Create Script >> Make it executable >> "Install" script via update-rc.d
cat << 'EOL' >/etc/init.d/StartVM
#!/bin/sh
#Edit these variables!
VMUSER=user
VMNAME=VM1
VMNAME2=Test
case "$1" in
start)
echo "Starting VirtualBox VM ..."
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME &
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME2 &
;;
stop)
echo "Saving state of Virtualbox VM ..."
sudo -u $VMUSER VBoxManage controlvm $VMNAME savestate
sudo -u $VMUSER VBoxManage controlvm $VMNAME2 acpipowerbutton
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0
EOL
sudo chmod +x /etc/init.d/StartVM
sudo update-rc.d StartVM defaults
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
add a comment |
Create Script >> Make it executable >> "Install" script via update-rc.d
cat << 'EOL' >/etc/init.d/StartVM
#!/bin/sh
#Edit these variables!
VMUSER=user
VMNAME=VM1
VMNAME2=Test
case "$1" in
start)
echo "Starting VirtualBox VM ..."
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME &
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME2 &
;;
stop)
echo "Saving state of Virtualbox VM ..."
sudo -u $VMUSER VBoxManage controlvm $VMNAME savestate
sudo -u $VMUSER VBoxManage controlvm $VMNAME2 acpipowerbutton
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0
EOL
sudo chmod +x /etc/init.d/StartVM
sudo update-rc.d StartVM defaults
Create Script >> Make it executable >> "Install" script via update-rc.d
cat << 'EOL' >/etc/init.d/StartVM
#!/bin/sh
#Edit these variables!
VMUSER=user
VMNAME=VM1
VMNAME2=Test
case "$1" in
start)
echo "Starting VirtualBox VM ..."
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME &
sudo -u $VMUSER VBoxHeadless --startvm $VMNAME2 &
;;
stop)
echo "Saving state of Virtualbox VM ..."
sudo -u $VMUSER VBoxManage controlvm $VMNAME savestate
sudo -u $VMUSER VBoxManage controlvm $VMNAME2 acpipowerbutton
;;
*)
echo "Usage: /etc/init.d/StartVM {start|stop}"
exit 1
;;
esac
exit 0
EOL
sudo chmod +x /etc/init.d/StartVM
sudo update-rc.d StartVM defaults
edited 2 mins ago
answered Oct 24 '15 at 2:37
FreeSoftwareServers
98331836
98331836
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
add a comment |
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
Original Thread, slightly changed and picked best answer IMO, just giving credit here
– FreeSoftwareServers
Oct 24 '15 at 2:41
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
This is with Ubuntu Server 14.04 x64 and Vbox 5.*
– FreeSoftwareServers
Oct 24 '15 at 2:42
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f238287%2fautostart-virtual-machine-vboxheadless-at-boot-with-upstart-init-and-graceful%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@reboot trail and error and failing post just for reference
– FreeSoftwareServers
Oct 24 '15 at 2:41