Skip to content

Instantly share code, notes, and snippets.

@oxagast
Created January 29, 2025 15:26
Show Gist options
  • Save oxagast/223d49b45eff08dd92a2faa162e49410 to your computer and use it in GitHub Desktop.
Save oxagast/223d49b45eff08dd92a2faa162e49410 to your computer and use it in GitHub Desktop.
Systemd service that starts and stops VirtualBox VMs gracefully.
[Unit]
Description= Guest VM %I
After=network.target vboxdrv.service
Before=runlevel2.target shutdown.target
[Service]
User=marshall
Group=vboxusers
Type=forking
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment