LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-24-2016, 09:41 AM   #1
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Rep: Reputation: 56
VirtualBox autostart guest at boot


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
 
Old 12-24-2016, 01:53 PM   #2
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, Debian 12, Devuan & MX Linux
Posts: 9,528
Blog Entries: 15

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
I'm honestly not sure what's wrong nor am I good with systemd; but these links might help.

https://www.marki-online.net/myblog/...s-for-systemd/

http://www.ericerfanian.com/automati...using-systemd/

Systemd Tips and Tricks
https://www.google.com/search?biw=13...k1.2hB01YdBwg0
 
1 members found this post helpful.
Old 12-25-2016, 03:54 AM   #3
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by Ztcoracat View Post
The solution from the second link worked out very well.

Thanks
 
Old 12-25-2016, 09:44 AM   #4
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, Debian 12, Devuan & MX Linux
Posts: 9,528
Blog Entries: 15

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
Quote:
Originally Posted by ddenial View Post
The solution from the second link worked out very well.

Thanks
That's great! Glad to hear the good news!

Merry Christmas

(if you celebrate it)

Last edited by Ztcoracat; 12-25-2016 at 09:46 AM.
 
Old 12-25-2016, 09:56 AM   #5
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by Ztcoracat View Post
That's great! Glad to hear the good news!

Merry Christmas

(if you celebrate it)
I'm a Hindu married to a Christian girl. Yes I'm celebrating Christmas. Merry Christmas to you too. 🎄

Thanks
 
Old 12-25-2016, 10:12 AM   #6
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, Debian 12, Devuan & MX Linux
Posts: 9,528
Blog Entries: 15

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
Quote:
Originally Posted by ddenial View Post
I'm a Hindu married to a Christian girl. Yes I'm celebrating Christmas. Merry Christmas to you too. 🎄

Thanks
You're Welcome!
Thanks and have a great day!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CentOS 7 Host and Virtualbox Win 8.1 Guest with Guest Additions Installed Sum1 Linux - Virtualization and Cloud 1 03-26-2015 02:31 PM
[SOLVED] how to check version of virtualbox guest additions currently installed in guest syste masuch Linux - Virtualization and Cloud 3 09-03-2012 01:05 AM
Host Fedora14, Windows 7 is running as Virtualbox guest- Mic is not working on Guest mwaheed Linux - Virtualization and Cloud 1 10-20-2011 12:51 PM
Problem installing guest additions on virtualbox Centos 5.5 64bit guest eljay313 Linux - Virtualization and Cloud 1 09-03-2010 08:22 AM
LXer: Install Guest additions and run fullscreen mode on VirtualBox Guest OS | Linux LXer Syndicated Linux News 0 01-17-2010 05:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration