请问大佬们, PVE 主机关机时如何挂起虚拟机而不是关机?

167 天前
 xixiv5
我刚从 hyper-v 迁移过来 PVE ,hyper-v 是有这个功能的,可以选择本机关机时将虚拟机睡眠,下次开机时自动恢复之前的状态。
PVE 里我找了好久没找到这个功能,请问是需要用什么命令才能打开吗?
1582 次点击
所在节点    程序员
11 条回复
memorybox
167 天前
好像没有这个功能;只能手工快照,然后重启后手工恢复快照
xixiv5
167 天前
@memorybox 这么难受吗,我本想是当 UPS 发送关机指令后,让其自动休眠所有虚拟机然后自身关机的
TsubasaHanekaw
167 天前
有的啊. 虚拟机列表右键就有?
iloveayu
167 天前
不可以,PVE 没有这个功能。
TsubasaHanekaw
167 天前
qm suspend vmId
TsubasaHanekaw
167 天前
Hibernation
You can suspend a VM to disk with the GUI option Hibernate or with

# qm suspend ID --todisk
That means that the current content of the memory will be saved onto disk and the VM gets stopped. On the next start, the memory content will be loaded and the VM can continue where it was left off.

State storage selection
If no target storage for the memory is given, it will be automatically chosen, the first of:

The storage vmstatestorage from the VM config.

The first shared storage from any VM disk.

The first non-shared storage from any VM disk.

The storage local as a fallback.

icon
icon
美式男声
arrow
595/5000
icon
冬眠
您可以使用 GUI 选项 Hibernate 或使用

#qm 挂起 ID--todisk
这意味着记忆的当前内容将被保存到磁盘上,虚拟机将停止。下一次启动时,记忆内容将被加载,虚拟机可以从中断的地方继续。

状态存储选择
如果没有给出记忆的目标存储,它将被自动选择,第一个:

VM 配置中的存储 vmstatestorage 。

来自任何 VM 磁盘的第一个共享存储。

来自任何 VM 磁盘的第一个非共享存储。

存储本地作为兜底。
memorybox
167 天前
我是 PVE7.1 , 好像无论是界面上点 Pause ,还是命令行 suspend ,只要 PVE 主机重启了,这个状态是不会保存的;
tsanie
167 天前
@memorybox qm suspend <vmid> --todisk 1 ,将在 storage 里持久化保存一个 state-suspend 的存储文件,也可以通过--statestorage <string>指定存储位置。
或者在 gui 上右键点 hibernate ,pause 用的是默认参数,--todisk 为 0 ,相当于 sleep 。
CoolZxp
167 天前
需要两步操作先用 bulk suspend 批量挂起之后再关机或者重启,也不麻烦。下次开机的时候设置自动启动的 vm 会自动从挂起中恢复。没设置自动启动的需要手动启动或者批量启动。
memorybox
167 天前
@tsanie 学到了,多谢多谢
xixiv5
167 天前
@CoolZxp
@tsanie
@memorybox
@TsubasaHanekaw

谢谢各位的回复,既然无法自动挂起的话,那现在的最优解决方式就是写个脚本 先批量挂起随后再关机自身了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/996713

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX