Hi
My host OS is Ubuntu 16.10, and I want to auto-start CentOS Virtualbox guest at boot and auto-shutdown at poweroff. The guest OS is called cent.
I followed this tutorial
Autostarting VirtualBox Virtual Machines
The only change I made from above tutorial is that I created a service unit file against initd startup method as mentioned in tutorial.
This is my service unit file:
Code:
$ ls -l /etc/systemd/system/vbox.service
lrwxrwxrwx 1 root root 34 Dec 24 19:46 /etc/systemd/system/vbox.service -> /usr/lib/systemd/user/vbox.service
$ cat /etc/systemd/system/vbox.service
[Unit]
Description=VBox Virtual Machine cent Service
[Service]
Type=simple
User=ddenial
Group=vboxusers
ExecStart=/usr/bin/VBoxManage startvm cent --type headless
ExecStop=/usr/bin/VBoxManage controlvm cent acpipowerbutton
[Install]
WantedBy=multi-user.target
When I start the service, cent virtualbox guest start correctly. This is status of service.
Code:
$ sudo systemctl start vbox.service
$ sudo systemctl status vbox.service
● vbox.service - VBox Virtual Machine cent Service
Loaded: loaded (/usr/lib/systemd/user/vbox.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2016-12-24 20:51:40 IST; 3min 55s ago
Process: 3060 ExecStop=/usr/bin/VBoxManage controlvm cent acpipowerbutton (code=exited, status=0/SUCCESS)
Process: 3013 ExecStart=/usr/bin/VBoxManage startvm cent --type headless (code=exited, status=0/SUCCESS)
Main PID: 3013 (code=exited, status=0/SUCCESS)
Dec 24 20:51:39 ubu systemd[1]: Started VBox Virtual Machine cent Service.
If I try to stop the service though, the guest wont shutdown. The following is status after service is stopped.
Code:
$ sudo systemctl stop vbox.service
$ sudo systemctl status vbox.service
● vbox.service - VBox Virtual Machine cent Service
Loaded: loaded (/usr/lib/systemd/user/vbox.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2016-12-24 20:51:40 IST; 11min ago
Process: 3060 ExecStop=/usr/bin/VBoxManage controlvm cent acpipowerbutton (code=exited, status=0/SUCCESS)
Process: 3013 ExecStart=/usr/bin/VBoxManage startvm cent --type headless (code=exited, status=0/SUCCESS)
Main PID: 3013 (code=exited, status=0/SUCCESS)
Dec 24 20:51:39 ubu systemd[1]: Started VBox Virtual Machine cent Service.
I have also enabled the service to start at boot. It wont work either, ie., guest cent Os wont start at Ubuntu host boot.
Code:
$ sudo systemctl enable vbox.service
What I'm doing wrong? Please help.
Thanks