Tue, October 2, 2018 · 2 min read

Converting vmware vmdk images to kvm qcow2 images

Converting vmware vmdk images to kvm qcow2 images

Red hat certifications are one of the most demanding in the IT industry. I wanted to get started with planning working towards getting RHCE certified. While preparing for RHCE certification one of the recommended book is Red Hat RHCSA/RHCE 7 Cert Guide: Red Hat Enterprise Linux 7 (EX200 and EX300). I had brought this book on amazon, it comes with lab guides and vm images that can be used to try the practicals listed in the book.

The vm images shipped were of extension .vmdk native to vmware. On my current laptop fedora is running as a primary os, I had to convert the images from .vmdk to .qcow2 format. When booted from the converted images I ran into booting issues, also the vm’s had predefined network settings custom gateway set, when booted from kvm it was fetching ip from the dhcp rather than taking the network settings from configuration files.

  1. Converting the .vmdk images to .qcow2:
qemu-img convert -f qcow2 -O qcow2 server1.vmdk server1.qcow2
qemu-img convert -f raw -O qcow2 server1.img server1.qcow2
  1. Due to udev rules, the vm’s booted from kvm will not take the network interface from configuration. To avoid this we can remove the udev rules:
sudo rm /etc/udev/rules.d/70-persistent.rules

NetworkManager has to be disabled/masked as it caused conflict with network service:

sudo systemctl mask NetworkManager
sudo systemctl restart network
  1. Creating a new virsh network using virsh-define with a custom gateway ip address:
virsh net-list
virsh net-destroy cipher-nat2
virsh net-edit cipher-nat2
virsh net-start cipher-nat2

After this the vm’s imported will have the intended network configuration and can be used with kvm hypervisor.