Skip to main content

Auto start VirtualBox guest on system reboot (Ubuntu 16.04)

Here's how to turn on guest OS in VirtualBox automatically when host PC is turned on. In this guide I use Ubuntu 16.04 LTS 64bit and VirtualBox 5.1.22

All we need to do is create a file with the extension * .service and put in the /lib/systemd/system folder. In this guide use the autostartvbox.service file name as an example.

sudo nano /lib/systemd/system/autostartvbox.service

  The contents of the file are as follows
#!/bin/sh
[Unit]
Description=Autostart VBOX Guest on Boot

[Service]
User=your_user
ExecStart=/usr/bin/VBoxHeadless --startvm VirtualBox_Guest_Name

[Install]
WantedBy=multi-user.target
 
  allows the service to run when the system boot with the following command
sudo systemctl enable autostartvbox.service
 
  If successful then the feedback obtained is as follows
Created symlink from /etc/systemd/system/multi-user.target.wants/autostartvbox.service to /lib/systemd/system/autostartvbox.service
 
  Restart the PC to see the results. To disable this service use the following command
sudo systemctl disable autostartvbox.service

Comments

Popular posts from this blog

Ubuntu Server 16.04 : Connection via USB Android Tethering

As we know that Ubuntu Server by default does not have a GUI. It is certainly quite difficult to make internet connection via USB Android. Here's how to connect internet via USB and have been tried in Ubuntu Server version 16.04 LTS. Make sure your android phone already has internet connection Connect your android phone with server via USB cable From your android phone, click Settings menu -> Wireless and Network -> More -> Tethering & portable hotspo t and enable USB tethering In the ubuntu server terminal, use the command sudo ifconfig -a Sample display of this command enp0s29f7u5 Link encap:Ethernet HWaddr 08:00:27:38:7b:49 inet addr:192.168.201.7 Bcast:192.168.201.1 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe38:7b49/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3593205 errors:0 dropped:0 overruns:0 frame:0 TX packets:4328737 errors:0 dropped:0 overruns:0

Autostart VirtualBox VM on Ubuntu Server 18.04 Boot

Create a configuration file in /etc/default/ sudo nano /etc/default/virtualbox then add VBOXAUTOSTART_DB=/etc/vbox VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg Then create a configuration file in  /etc/vbox/ sudo nano /etc/vbox/autostart.cfg then add default_policy = deny # Create an entry for each user allowed to use autostart myusername = { allow = true } sudo chgrp vboxusers /etc/vbox sudo chmod 1775 /etc/vbox sudo usermod -aG vboxusers USERNAME VBoxManage setproperty autostartdbpath /etc/vbox Use the following command to get a list of available vms vboxmanage list vms Create a file with <username>.start on /etc/vbox sudo touch /etc/vbox/username.start sudo chown username /etc/vbox/username.start Restart the virtualbox service for changes to take effect sudo systemctl restart vboxautostart-service Specify the virtual machine that will be set to autostart VBoxManage modifyvm <uuid|vmname> --autostart-enabled <