Blog

03/06/2019

How to forcefully shutdown a guest VM using virsh command on Linux KVM



I used the command ‘virsh shutdown vm1’ to shut down a guest named vm1 using the virsh command. However, it is still running, and my vm1 is not responding to an ssh session. Is there is a way to forcefully stop or kill a guest VM using the virsh command from host server?

You can alway force a guest domain/VM to stop with the virsh command. This command does an immediate ungraceful shutdown of VM. Let us see how to force a guest to stop and risk associated with it on Linux KVM.

How to shut down a guest vm gracefully

The syntax is:
# virsh shutdown domain
# virsh shutdown vm
# virsh shutdown freebsd
# virsh shutdown ubuntu1

How to shut down a guest vm immediately (forceful shutdown)

The syntax is:
# virsh destroy domain
# virsh destroy vm
# virsh destroy freebsd
# virsh destroy ubuntu1

Sample sessin:

Fig.01: Virsh command for forcing a guest to stop

The above command works but it can also corrupt guest file system but leave its resources intact. Hence I recommend to backup your VM everyday or at least backup important files including database.

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

20/08/2019

Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...
14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....