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.

ADVERTISEMENTS

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

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.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.