V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xixiv5
V2EX  ›  程序员

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

  •  
  •   xixiv5 · 150 天前 · 1541 次点击
    这是一个创建于 150 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我刚从 hyper-v 迁移过来 PVE ,hyper-v 是有这个功能的,可以选择本机关机时将虚拟机睡眠,下次开机时自动恢复之前的状态。
    PVE 里我找了好久没找到这个功能,请问是需要用什么命令才能打开吗?
    11 条回复    2023-12-01 20:55:27 +08:00
    memorybox
        1
    memorybox  
       150 天前
    好像没有这个功能;只能手工快照,然后重启后手工恢复快照
    xixiv5
        2
    xixiv5  
    OP
       150 天前
    @memorybox 这么难受吗,我本想是当 UPS 发送关机指令后,让其自动休眠所有虚拟机然后自身关机的
    TsubasaHanekaw
        3
    TsubasaHanekaw  
       150 天前
    有的啊. 虚拟机列表右键就有?
    iloveayu
        4
    iloveayu  
       150 天前
    不可以,PVE 没有这个功能。
    TsubasaHanekaw
        5
    TsubasaHanekaw  
       150 天前
    qm suspend vmId
    TsubasaHanekaw
        6
    TsubasaHanekaw  
       150 天前   ❤️ 1
    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
        7
    memorybox  
       150 天前
    我是 PVE7.1 , 好像无论是界面上点 Pause ,还是命令行 suspend ,只要 PVE 主机重启了,这个状态是不会保存的;
    tsanie
        8
    tsanie  
       150 天前   ❤️ 1
    @memorybox qm suspend <vmid> --todisk 1 ,将在 storage 里持久化保存一个 state-suspend 的存储文件,也可以通过--statestorage <string>指定存储位置。
    或者在 gui 上右键点 hibernate ,pause 用的是默认参数,--todisk 为 0 ,相当于 sleep 。
    CoolZxp
        9
    CoolZxp  
       150 天前
    需要两步操作先用 bulk suspend 批量挂起之后再关机或者重启,也不麻烦。下次开机的时候设置自动启动的 vm 会自动从挂起中恢复。没设置自动启动的需要手动启动或者批量启动。
    memorybox
        10
    memorybox  
       150 天前
    @tsanie 学到了,多谢多谢
    xixiv5
        11
    xixiv5  
    OP
       150 天前
    @CoolZxp
    @tsanie
    @memorybox
    @TsubasaHanekaw

    谢谢各位的回复,既然无法自动挂起的话,那现在的最优解决方式就是写个脚本 先批量挂起随后再关机自身了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1081 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:44 · PVG 02:44 · LAX 11:44 · JFK 14:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.