this article addresses a common issue that happens when you use xm destroy command. Hence it will show how to solve this issue and restore vanished VMs.
What is XM?
xm command is a program that allows you to manage Xen virtualization guest virtual machines. In other words, This program can list, create, pause, and shutdown VMs. in addition, it controls the machine’s virtual block devices. though it’s very powerful, it does not handle error checking or configuration file errors very well and mistakes can lead to system instability or errors in virtual machines. Therefore, in future you should use virsh
or virt-manager
commands instead.
I was taking a course one of the tasks is to crash the server which runs the services. I applied the command to crash the VM
Linux XM command explained.
To take any action on XEN based virtual machines using xe command. generally, you need to add a parameter and define your target virtual machine.
xm <options> <Target>
XM options
xm list |
List active virtual machines |
xm create [-c] vmName/ID |
Start a virtual machine. If the -c option is used, the start up process will attach to the guest’s console.
|
xm consolevmName/ID |
Open a virtual machine’s console |
xm destroy vmName /ID |
Force a virtual machine to power off. |
xm reboot vmName /ID |
Reboot a virtual machine, runs through the normal system shut down and start up process.
|
xm shutdown vmName /ID |
Shut down a virtual machine, runs a normal system shut down procedure.
|
xm pause |
Pause virtual machine |
xm unpause |
Resume virtual machine |
xm start vmName |
Start powered off virtual machines |
problem xm destroy hide VMs, how to solve it ? .
It happens, that when you execute xm start command, it returns an error that there is no machine with that name, apparently, xm destroy hide the VM as if it’s deleted. moreover, When you list the available machines using xm –list. the machine does not show in the list.
The solution is to find where the config files of that VM. then, create a new virtual machine or rather I registered it again by executing
cd /location/of/vmFiles xm create <virtName.conf>
the result of this command creates a new instance of the virtual machine using its existing configuration files and registers it again. and by that, you will be able to restore that vanished vm