Skip to content

Instantly share code, notes, and snippets.

@SamMousa
Created September 14, 2020 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SamMousa/8d4a538f088dd24c9180c6929203a005 to your computer and use it in GitHub Desktop.
Save SamMousa/8d4a538f088dd24c9180c6929203a005 to your computer and use it in GitHub Desktop.
Virtualbox on ZFS in SystemD, proper shutdown and process management
# Inspired by https://blogging.dragon.org.uk/start-stop-virtualbox-with-systemd/
[Unit]
Description=Virtual Box Guest %I
After=network.target virtualbox.service zfs-volume-wait.service
Before=runlevel2.target shutdown.target
[Service]
User=root
Group=root
Type=simple
RemainAfterExit=no
ExecStart=/usr/bin/VBoxHeadless -s %i
ExecStop=-/usr/bin/VBoxManage controlvm %i acpipowerbutton
ExecStop=/usr/bin/bash -c 'until VBoxManage showvminfo DirectResearch | grep -E "^State:" | grep -v running; do sleep 1; done'
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment