How to manage Virtual Machines with QEMU/KVM and Libvirt on Debian

This is a short post to focus on a simple way to get a powerful system to manage virtual machines.

Software details

Installation of the Virtual Machines Manager

QEMU/KVM installation

sudo apt-get install qemu-kvm

Libvirt Installation

The minimum if you only need to manage via command lines :

sudo apt-get install libvirt-clients libvirt-daemon-system

It may be more comfortable to have a graphical interface (which is very easy to use, I can attest to that) :

sudo apt-get install virt-manager

All you need is installed

Now you can :

  • install new VM quickly
  • create snapshot before a major maintenance operation and rollback to a previous version if needed

Manage your Virtual Machines

Adding more space on a Virtual Machine

In this command line example, the goal is to add 10GB space on VIrtual Machine which the path is /mnt/vm/myvirtualmachine.qcow2 :

sudo qemu-img resize /mnt/vm/myvirtualmachine.qcow2 +10G

Restart a Virtual Network

Usually, you need it because a VM does not want to start if the Virtual Nework used for it is not started

First of all, list your Virtual Networks

sudo virsh net-list --all

By default, the result will be as following :

 Name      State      Autostart   Persistent
----------------------------------------------
 default   inactive   no          yes

So, to restart the default virtual network, you have to run the following command line (replacing “default” by the name of your virtual network if needed) :

sudo virsh net-start default

If every thing is allright, the response should be :

Network default started

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *