How to autostart homeassistant on virtual box on Xubuntu 22.04?

I have it working but have to start it manually. Found this page on autostarting:
https://community.home-assistant.io/t/ha-installed-with-virtualbox-on-ubuntu-how-to-autostart-image-after-reboot/573167
But when I tried to run it I got an error:


jim@jim-myth:~$ locate vboxmanage
/usr/bin/vboxmanage
/usr/share/man/man1/vboxmanage.1.gz
jim@jim-myth:~$ /usr/bin/vboxmanage modifyvm "homeassistant" --autostart-enabled on
VBoxManage: error: The path to the autostart database is not set
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "COMSETTER(AutostartEnabled)(ValueUnion.f)" at line 3171 of file VBoxManageModifyVM.cpp
jim@jim-myth:~$

Can’t you use the built-in services to restart the host? I use VMWare and can restart easily via automaton or scripting.

image

You also need to run the following once (under the account that will be doing the autostart):

vboxmanage setproperty autostartdbpath /etc/vbox/
sudo systemctl restart vboxautostart-service

I had missed some of the file setup steps but went back and did them. All looked good until the last step of restarting the service. Got:

Failed to restart vboxautostart-service.service: Unit vboxautostart-service.service not found.

Doesn’t look like the file for the service was created.

From what I have found the package in the ubuntu repositories lacks this and perhaps some other things. One suggestion was to use the Oracle’s repos . I used a simpler solution. Made desktop icon for virtual machine by right clicking on the vm. Then copied command from the icon and put that in startup list.
https://askubuntu.com/questions/404665/how-to-start-virtual-box-machines-automatically-when-booting

1 Like

After this working for a couple months it doesn’t auto start the virtual box and gives an error. Maybe due to some updates on the system? Here’s the error. Secure boot is NOT enabled in the host os. I tried reinstalling virtualbox-dkms but it still doesn’t auto start. I can start it manually and it all seems to work, just doesn’t auto start. I suppose I could wipe it and install from the Oracle repo but was hoping to avoid that and wondering how likely that is to fix this.