On my lubuntu 24.04 distribution I have installed the hypervisor Oracle VirtualBox 7.1.6 and I have imported a Virtual Machine (called my-virtual-machine below in this question).
Start and Power Off a Virtual Machine by command lines
I have found how to start and power off a Virtual Machine by command line:
- To start a Virtual Machine:
/usr/bin/VBoxManage startvm 'my-virtual-machine' --type gui
- To power off a Virtual Machine:
/usr/bin/VBoxManage controlvm 'my-virtual-machine' acpipowerbutton
Descriptions of my needs
I have the following needs:
- to start
my-virtual-machine(the Guest) automatically at boot time of my Host (that is lubuntu 24.04) - to Power Off
my-virtual-machineat the shutdown of the Host - the Virtual Machine must to be start with the GUI and not headless
By this post, which is very old and refers to VirtalBox 4.2 but seems yet valid for VirtualBox 7.1, I'm able to solve my first request and perhaps the second request.
The problem is the third request because the method explained by the post allows to start the virtual machine at boot of the Host system but in headless mode and not with the GUI.
When the Vitual Machine is correctly started I can see the following 2 process by ps aux command:
> ps aux | grep VBox
[...] /usr/lib/virtualbox/VBoxHeadless --comment my-virtual-machine --startvm 546632bd-b8bd-4f2d-b2a1-8657b968378a --vrde config
[...] /usr/lib/virtualbox/VBoxSVC --auto-shutdown --inherit-startup-pipe 7
Question
How to start a Oracle VirtualBox VM with GUI (and not headless) at boot time of the Host system and power off the VM at the shutdown of the Host system?
