hibernate a VM via qm command

tincboy

Active Member
Apr 13, 2010
461
2
38
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?
 

Stoiko Ivanov

Proxmox Staff Member
Staff member
May 2, 2018
5,210
686
118
check the manpage of `qm` - for hibernation you use `qm suspend --todisk 1`

hope this helps!
 
Feb 17, 2020
53
2
8
41
@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.
 

Jannoke

Member
Jul 13, 2016
28
4
23
37
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?
 
Feb 17, 2020
53
2
8
41
@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.
 
Feb 17, 2020
53
2
8
41
@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 :)
 

Jannoke

Member
Jul 13, 2016
28
4
23
37
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.
 

budy

Member
Jan 31, 2020
194
9
18
54
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.
 

masgo

Member
Jun 24, 2019
38
2
8
71
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

Member
Jul 13, 2016
28
4
23
37
@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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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!