Feature request: Hibernate VMs on PVE host reboot

Feb 17, 2020
80
7
8
42
I thought it would be cool to have an option to hibernate VMs (instead of shutdown) on PVE host reboot. It's especially handy when VMs require manual intervention for startup.

Any thoughts on this?
 
  • Like
Reactions: CanadaGuy

tom

Proxmox Staff Member
Staff member
Aug 29, 2006
15,504
894
163
You can hibernate already manually, a general setting to do this on host reboot in already on our internal roadmap.
 
Feb 17, 2020
80
7
8
42
@Radek Kantor or anyone else it could help, I'm using the following script to automate the process:

Code:
# suspend_and_shutdown.sh
qm list | grep running | awk -F'[^0-9]*' '$0=$2' | while read -r vm_id; do qm suspend $vm_id --todisk 1; done; shutdown -h now

# suspend_and_reboot.sh
qm list | grep running | awk -F'[^0-9]*' '$0=$2' | while read -r vm_id; do qm suspend $vm_id --todisk 1; done; reboot

I'm quite happy with my scripts, although I would still appreciate this being built in.
 

Lion3000

New Member
Feb 18, 2022
1
2
3
26
France
breachless-solutions.com
Hi,

Here is my solution to hibernate all VMs at reboot or shutdown !
It works for me. Thanks to @davidand for his script example :)

Go in proxmox shell, you need to be root !

vi /etc/init.d/proxmox

Add this :

Bash:
#!/bin/sh
case "$1" in
start)
   qm list | awk -F'[^0-9]*' '$0=$2' | while read -r vm_id; do qm unlock $vm_id; done;
;;
stop)
   qm list | grep running | awk -F'[^0-9]*' '$0=$2' | while read -r vm_id; do qm suspend $vm_id --todisk 1; done;
   sleep 10
;;
esac
exit 0

chmod 755 /etc/init.d/proxmox

ln -s /etc/init.d/proxmox /etc/rc3.d/S99proxmox
ln -s /etc/init.d/proxmox /etc/rc0.d/K99proxmox
ln -s /etc/init.d/proxmox /etc/rc6.d/K99proxmox

systemctl daemon-reload
systemctl start proxmox

Don't forget to add autostart option in proxmox to the VMs that have to boot on start.

Enjoy ! :)

You can reboot or shutown your server from :
- Physical buttons
- Proxmox Gui buttons
- in shell : restart now / shutdow now
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!