hibernate a VM via qm command

tincboy

Renowned Member
Apr 13, 2010
466
5
83
I didn't find proper qm command options to hibernate or resume a VM via terminal,
Would you please let me know what are the options if any?
 
check the manpage of `qm` - for hibernation you use `qm suspend --todisk 1`

hope this helps!
 
@masgo Yes, I think it does. I did:

1) qm suspend 100 --todisk 1
2) rebooted PVE
3) VM started automatically
- lastlog from the VM showed last reboot about a month ago

Therefore I think yes, it works like you described.
 
  • Like
Reactions: Tmanok
For me the confusing part is that where is the hibernation data kept? We got some guest machines with 250GB+ ram, so where will this all pushed?
 
  • Like
Reactions: Tmanok
@Jannoke Although I don't have any exact knowledge of this, this might be useful from the documentation:

https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_hibernate
State storage selection
If no target storage for the memory is given, it will be automatically chosen, the first of:
  1. The storage vmstatestorage from the VM config.
  2. The first shared storage from any VM disk.
  3. The first non-shared storage from any VM disk.
  4. The storage local as a fallback.
 
@Jannoke I did a small test and for me it did create a new volume:

root@proxmox:~# qm suspend 103 --todisk 1
Logical volume "vm-103-state-suspend-2020-05-10" created.

1589106868975.png

root@proxmox:~# qm resume 103
Resuming suspended VM
activating and using 'local-lvm:vm-103-state-suspend-2020-05-10' as vmstate
Resumed VM, removing state
Logical volume "vm-103-state-suspend-2020-05-10" successfully removed

Pretty neat :)
 
Yes I tested that out also. Got an extra file in my zfs pool. Also it seems it wil dump only needed memory and size of the "hibernate" file depends on the current ram usage. So for faster standby/resume echo 3 >/proc/sys/vm/drop_caches is one way to go. I use it also to make migrations faster between nodes.
 
Well… the quest could probably hibernate itself after flushing the caches, if one would let it use the PVE api to hibernate itself. Otherwise, the qm command would have to be issued from the PVE host and that one has of course no knowledge as of when or if the cashes have been flushed out.
 
Well… the quest could probably hibernate itself after flushing the caches, if one would let it use the PVE api to hibernate itself. Otherwise, the qm command would have to be issued from the PVE host and that one has of course no knowledge as of when or if the cashes have been flushed out.
Seems to me like a job for the Agent. Would be really nice to have an option where qm suspend would flush the cache from within the guest.

Obviously, this should not be the default.
 
@Jannoke Interesting approach! Do you issue it on the host machine or inside the VMs? Do you need to wait for a certain time after the 'echo' command?
The command is blocking. It means it will not return before it's complete. If you have a lot of ram (100+GB etc.) then you can actually see it decreasing from proxmox webui under status. Depending on the machine the flushing can occur on ranges of 5-30GB/s.
 
Yes I tested that out also. Got an extra file in my zfs pool. Also it seems it wil dump only needed memory and size of the "hibernate" file depends on the current ram usage. So for faster standby/resume echo 3 >/proc/sys/vm/drop_caches is one way to go. I use it also to make migrations faster between nodes.
Can you please detail this a bit? Thank you
 

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 yours easily in our online shop.

Buy now!