8.3. Restarting a virtual machine by using the command line


Restarting a virtual machine (VM) requires different steps based on whether the VM is responsive.

Procedure

  • Restarting a responsive VM

    • If you are connected to the guest, use a restart command or a GUI element appropriate to the guest operating system.
    • Alternatively, use the virsh reboot command on the host:

      • If the VM is on a local host:

        # virsh reboot demo-guest1
        Domain 'demo-guest1' is being rebooted
      • If the VM is on a remote host, in this example 192.0.2.1:

        # virsh -c qemu+ssh://root@192.0.2.1/system reboot demo-guest1
        
        root@192.0.2.1's password:
        Domain 'demo-guest1' is being rebooted
  • Restarting an unresponsive VM

    1. Force a VM to shut down.

      # virsh destroy demo-guest1
      Domain 'demo-guest1' destroyed
      注意

      The virsh destroy command does not actually delete or remove the VM configuration or disk images. It only terminates the running instance of the VM, similarly to pulling the power cord from a physical machine.

      In rare cases, virsh destroy may cause corruption of the VM’s file system, so use this command only if all other shutdown methods have failed.

    2. Start the VM again.

      # virsh start demo-guest1
      Domain 'demo-guest1' started

Verification

  • On the host, display the list of your VMs to see their status.

    # virsh list --all
    
     Id    Name                 State
    ------------------------------------------
     1     demo-guest1          running
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部