Delay Proxmox VE VM Autostart
#Proxmox #Hypervisor #DelayedAutostart
Full steps can be found at https://i12bretro.github.io/tutorials/0774.html
--------------------------------------------------------------------
Background?
--------------------------------------------------------------------
I have a Proxmox node that hosts my Windows domain controller. Part of the hardware setup for the VM is a USB 3.0 PCI card that allows me to control the devices (mostly external HDDs) directly from within the VM. The problem I was running into was whenever my Proxmox host rebooted or lost power and came back up, the USB 3.0 PCI card wouldn't passthrough properly. I'd have to manually shutdown the VM, then start it for the passthrough to work. I figured that since a simple stop/start of the VM was fixing the passthrough it had something to do with the timing of the Proxmox host releasing the PCI device before the Windows VM started it's boot process. I started investigating how to delay starting the VMs with the autostart option enabled and came across this blog post https://dannyda.com/2020/06/24/how-to-delay-the-first-auto-start-virtual-machinevm-guest-system-in-proxmox-ve-pve/ with a very straightforward and simple solution. This is also a viable solution for those who use NAS or other externally hosted storage for their VMs and want to allow additional time for that hardware to become available prior to Proxmox starting VMs.
01. Log into the Proxmox web UI
02. Select the target node ≫ Shell
03. Run the following commands in the terminal
# create a backup of the pve-guests service
cp /etc/systemd/system/multi-user.target.wants/pve-guests.service ~/pve-guests.service.bkup
# edit the pve-guests service file
nano /etc/systemd/system/multi-user.target.wants/pve-guests.service
04. Press CTRL+W and search for ExecStartPre
05. Add the following before the existing ExecStartPre line, changing the 60 to the number seconds to delay the startup of VMs
ExecStartPre=/bin/sleep 60
06. Press CTRL+O, Enter, CTRL+X to write the changes
07. That's it. The next time the Proxmox node reboots the auto starting of VMs will be delayed by the specified number of seconds, allowing more time for dependent hardware or storage to become available
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro