G
G
ghostku2015-06-01 21:18:31
virtual box
ghostku, 2015-06-01 21:18:31

How to set VirtualBox VM to autostart on host startup?

Good afternoon
System: Ubuntu 14.04.2 LTS + VirtualBox 4.3.28
User running Virtual machines: vbox
Virtual machines:

vboxmanage list vms
"1C" {c653127b-89e4-4d5d-a41a-e5f3ae4212c0}
"Win7ENG" {01dced55-6fe9-4906-b96c-694d8357a6af}

Task: Set up autostart of Virtual Machine "1C: when starting the host. In the process of setting up, I use this manual , which describes the new features that have appeared in virtualbox 4.2.
I tried to set it up several times, I still get the same thing:
1 - As I understand it, when I write a command vboxmanage modifyvm VM_NAME --autostart-enabled on- then the USERNAME.start file should appear in the VBOXAUTOSTART_DB folder (/etc/vbox).So this file appears only if I execute the command vboxmanage modifyvm VM_NAME --autostart-enabled onfor both of my existing machines.Accordingly, when I run service vboxautostart-service startit, it either does nothing (when there is no file ), or starts both machines (when the file exists), I can't start only one machine.
2 - If you leave this file and restart the host, then none of the machines will start anyway and their statuses will remain the same as they were before the reboot, that is, it turns out that there are no attempts to even start.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mureevms, 2015-06-01
@mureevms

I didn’t quite understand how you did it, but you can simply start the VM like this:
Create a file
With the following content:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO
vboxmanage startvm 1C
vboxmanage startvm Win7ENG

Then make the script executable and add to autostart:
chmod +x /etc/init.d/vm_start.sh
update-rc.d vm_start.sh  defaults

After restarting the machine, the two specified virtual machines will start.

A
Andrey Raboy, 2018-03-01
@raba

Try to write the command in /usr/rc.local:
sudo su -c "VBoxManage startvm vmname --type headless" username
startvm - name of the virtual machine
username - username from which the virtual machines are spinning, the fact is that the command is executed from root and you need to specify the user in whose home folder the virtual machines were lying
helped me)) here in detail

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question