Jump to content


Photo
- - - - -

Ubuntu 18.04 Start Stop VirtualBox


  • Please log in to reply
No replies to this topic

#1 pete_c

pete_c

    Cocoonut

  • -=Gold Supporter=-
  • 9439 posts
  • Location:House
  • Experience:average
  • Software:Main Lobby, Open Source Automation
  • Hardware:HAI OmniPro II, Mi Casa Verde Vera, Ocelot
  • Tech:X10-PLC, X10-RF, UPB, INSTEON, Z-Wave, ZigBee, 1-Wire, xAP, xPL, ALC
  • Audio:Russound
  • Video:MythTV
  • CCTV:analog, ip, dvr
  • Phone:Asterisk, FreePBX, Ooma, POTS, VoIP via ISP

Posted 06 April 2019 - 11:16 AM

Here have been running a Windows VB on my main automation server which is running Ubuntu 18.04 64 bit and recently upgraded to VirtualBox 6.0.

 

I have had issues autostarting the VB using standard virtual box autostart. 

 

Found a new way to do this this morning and it works well.

 

Documenting here on a post.

 

Get rid of vboxautostart-service

 

1 - sudo systemctl disable vboxautostart-service

2 - sudo rm -rf /lib/systemd/system/vboxautostart-service.service

3 - sudo rm -rf /etc/vbox

 

User permissions for Virtualbox

 

1 - type groups to see if you are in the vboxusers group
 

IE:

[email protected]:~$ groups
pete adm cdrom sudo dip plugdev lpadmin sambashare vboxusers
 

2 - if not put yourself in the vboxusers group typing:

sudo usermod -a -G vboxusers pete

 

3 - type groups again to make sure you are in the group vboxusers

 

New Unit File for systemd

 

1 - Create a new Unit file

sudo nano /etc/systemd/system/vm_autostart_name.service

IE: sudo nano /etc/systemd/system/vm_autostart_W7.service

 

2 - use this text as a template: (I used vm_name=W7)

[Unit]
Description=VM vm_name
After=network.target vboxdrv.service
Before=runlevel2.target shutdown.target
 
[Service]
User=pete
Group=vboxusers
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
 
ExecStart=/usr/bin/VBoxManage startvm vm_name --type headless
ExecStop=/usr/bin/VBoxManage controlvm vm_name acpipowerbutton
 
[Install]
WantedBy=multi-user.target

 

Reload systemd daemon

 

sudo systemctl daemon-reload

 

Using the service

 

1 - Enable the service

 

sudo systemctl enable vm_autostart_name

 

2 - Start, Stop and Status of service

 

sudo systemctl start vm_autostart_name
sudo systemctl stop vm_autostart_name
sudo systemctl status vm_autostart_name

 

That's it.  Works great over here.

 

 

 

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users