Project

General

Profile

VirtualBox » History » Version 1

Charles Atkinson, 17/08/2020 15:45
Creation

1 1 Charles Atkinson
h1. VirtualBox
2 1 Charles Atkinson
3 1 Charles Atkinson
{{toc}}
4 1 Charles Atkinson
5 1 Charles Atkinson
h1. Start VMs at host boot and shut down during host shutdown using systemd
6 1 Charles Atkinson
7 1 Charles Atkinson
h2. Script
8 1 Charles Atkinson
9 1 Charles Atkinson
"/usr/local/bin/shut_down_vbox_vm.sh":https://redmine.auroville.org.in/attachments/download/7747/shut_down_vbox_vm.sh
10 1 Charles Atkinson
11 1 Charles Atkinson
h2. /etc/systemd/system/vboxvmservice@.service
12 1 Charles Atkinson
13 1 Charles Atkinson
This is specific to the User= user
14 1 Charles Atkinson
<pre>
15 1 Charles Atkinson
[Unit]
16 1 Charles Atkinson
Description=VBox Virtual Machine %i Service
17 1 Charles Atkinson
Requires=systemd-modules-load.service
18 1 Charles Atkinson
After=systemd-modules-load.service
19 1 Charles Atkinson
20 1 Charles Atkinson
[Service]
21 1 Charles Atkinson
User=c
22 1 Charles Atkinson
Group=vboxusers
23 1 Charles Atkinson
ExecStart=/usr/bin/VBoxManage startvm %i --type headless
24 1 Charles Atkinson
ExecStop=/usr/local/bin/shut_down_vbox_vm.sh %i
25 1 Charles Atkinson
RemainAfterExit=yes
26 1 Charles Atkinson
27 1 Charles Atkinson
[Install]
28 1 Charles Atkinson
WantedBy=multi-user.target
29 1 Charles Atkinson
</pre>
30 1 Charles Atkinson
31 1 Charles Atkinson
h2. Instantiation
32 1 Charles Atkinson
33 1 Charles Atkinson
Example, for user c's VM aems3.iciti.av
34 1 Charles Atkinson
<pre>
35 1 Charles Atkinson
# systemctl enable vboxvmservice@aems3.iciti.av
36 1 Charles Atkinson
</pre>