-
What is Virsh command?
-
How to install virsh?
-
How to create KVM VM with Virsh command?
-
How to backup and manage KVM VM with Vinchin Backup & Recovery?
-
Sum Up
KVM is a popular hypervisor for virtual environment deployment on Linux operating system. After the server is virtualized, IT administrators can create VMs to support all kinds of business systems.
Creating VM is the first step after hypervisor is installed and you will have multiple ways to create new VM.
What is Virsh command?
KVM VM can be managed by libvirt and for this type of VM, IT administrator can use virsh command to manage it, including creating and exporting VM.
Virsh is actually a toolkit and API and also the default management tool for KVM virtual environment management. If you haven’t installed graphical virtual machine manager like virt-manager, you still have virsh command to manage the virtual environment. Virsh command can help you manage not only the local hypervisor, but also a remote hypervisor.
Virsh command can help you manage KVM virtual environment with hundreds of subcommands and the following sections will mainly introduce the way to create new VM with virsh command.
How to install virsh?
If you are using Ubuntu 20.04 release, Centos 8 or RHEL 8, you have to manually install virsh on the operating system and it is recommended to install the full package for KVM virtual environment management.
1. Update system
Run apt update -y or yum update -y (depending on your operating system) to update the system.
2. Install virsh
Run the command below to install the full package
apt install libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager -y
libvirt-daemon-system is used to give the libvirt daemon and a collection of tools for managing VMs.
libvirt-clients contains the virsh program.
bridge-utils is the program which creates and maintains Ethernet device bridges between Ethernet devices and the KVM guests on your host system.
Virtinst contains the command-line utility for new guest creation.
Virt-manager is the graphical interface for KVM VM management.
After that, you can check the version of virsh to verify whether it is successfully installed.
virsh --version
How to create KVM VM with Virsh command?
Virsh command allows you to create a new KVM VM from its configuration file, which is the xml file in datastore. You can get the xml file by exporting it from KVM VM.
virsh dumpxml target_guest_machine > /root/target_guest_machine.xml
Create a new VM with the xml file:
virsh create target_guest_machine.xml
Except for creating new VM, you can also create VM snapshot with virsh command:
virsh snapshot-create kvm_guest_name
You can also create a new VM from virtual disk image. To make sure you have the virtual disk file, you can find the directory of the VM and extract the virtual disk file, which is often saved as raw or qcow2 format.
The command below will help you find the directory of virtual disk file:
virsh domblklist guest_name
Then use virt-install command to create a new VM:
virt-install
--name guest1-rhel7
--memory 2048
--vcpus 2
--disk /path/to/imported/disk.qcow
--import
--os-variant rhel7
In addition, you can open virt-manager to create new VM in more simple way. Just click the icon below File option and finish the rest of jobs with the help of wizard.
How to backup and manage KVM VM with Vinchin Backup & Recovery?
Although virsh command can help you manage KVM environment, you can still upgrade your disaster recovery solution with Vinchin Backup & Recovery.
Vinchin Backup & Recovery is a professional backup and disaster recovery solution for KVM virtual environment management. It supports KVM environments like Red Hat Virtualization, oVirt, OpenStack, Oracle Linux KVM, etc.
With Vinchin Backup & Recovery, you can easily add all the KVM VMs to backup server agentlessly and manage backup system via a user-friendly web console.
KVM commands can only provide the basic disaster recovery solution like VM exporting and importing but with Vinchin Backup & Recovery, you can make a disaster recovery plan in every way. There are a lot of useful backup strategies, like scheduled backup, incremental backup, data compression, data encryption, etc. to help you configure different backup jobs.
Vinchin Instant Recovery technology will help you quickly recover a failed VM from its backup in 15 seconds and Vinchin Virtual Machine Convert Engine can allow you to easily perform V2V migration, recovering VM on a foreign hypervisor.
Vinchin Backup & Recovery has been selected by thousands of companies and you can also start to use this powerful system with a 60-day full-featured free trial. Just click the button to get the installation package.
Sum Up
KVM is a popular hypervisor for virtual environment deployment and virsh command the default management tool for KVM virtual environment.
This post mainly introduces how to install the management tools on Linux server and how to create new VM in every way.
You can also use Vinchin Backup & Recovery to protect and manage your KVM environment. Don’t miss the free trial.
Share on: