VirtualBox Systemd
To control the start/stop of your VM’s with systemd, and use systemd to auto start and stop them on system boot.
Run sudo systemctl edit vbox@.service --full --force and paste the following content in, updating User and Group to your username.
Before using the template below, confirm your VBoxManage path:
command -v VBoxManage
[Unit]
Description=Virtual Box Guest %I
After=network.target vboxdrv.service
Before=runlevel2.target shutdown.target
[Service]
User=USERNAME
Group=GROUPNAME
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/usr/bin/VBoxManage startvm %i --type headless
ExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton
[Install]
WantedBy=multi-user.target
Then, reload systemd: sudo systemctl daemon-reload
Get a list of your VM’s:
VBoxManage list vms
"Ubuntu" {1ba32309-d4c4-420a-a9c8-a38177f00bc4}
"Windows" {573df054-0e33-4389-896a-1234f10e25ad}
Use the name returned in step 3 to manage the VM via systemd. For example, to manage the “Ubuntu” VM you would run:
sudo systemctl start vbox@Ubuntu # Start the VM
sudo systemctl enable vbox@Ubuntu # Start the VM on boot
Update Changelog
- Changed On
2026-07-04
- Summary of Updates
Added
VBoxManagepath verification step before creating the systemd unit.
- Reason for Change
Reduce path-related failures on systems where VBoxManage is not in the expected location.
- Compatibility Notes
Unit example assumes systemd and a valid VBoxManage path on the host.
- Tested On
Documentation review only (commands not executed in this repo).