Converting vmware vmdk images to kvm qcow2 images

Red hat certifications are one of the most demanding in the 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) which covers topics in depth will good explanation.

I had brought this book on amazon, it comes with lab guides and vm images that can used to try the practicals listed in the book, to download the course had to register the ebook ISBN at http://www.pearsonitcertification.com and download the vm images.

The vm images shipped were of extenstion .vmdk native to vmware, on my current laptop fedora is running as a primary os 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 predifined 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.

we will look into how we can convert .vmdk images to .qcow2 , modify kvm default network or create a new network with a custom gateway that matches with the vm’s settings.

1. Converting the .vmdk images to .qcow2
vmware default images .vmdk can be converted into kvm/openstack image format qcow2, after converting the image when imported into kvm it would choose disk type to be virtio which is a default for linux and windows systems to improve I/O performance, while vmware image does not have virtio drivers installed hence if you directly import the image into virt-manager and try to boot you will run into boot issues ( vm’s goes into recovery mode) to fix the issue you need to modify disk type to IDE or SATA

Converting the vmdk image to qcow2 , while raw images have better read, write I/O rate compared to qcow2 images, we can convert qcow2 images to raw and use.

cipher  ~  qemu-img convert -f qcow2 -O qcow2 server1.vmdk server1.qcow2

cipher  ~  qemu-img convert -f raw -O qcow2 server1.img server1.qcow2

2.Due to udev rules , the vm’s booted from kvm will not take the network interface from configuration, udev rules will name interfaces to en** based on the type of ethernet type , to avoid this we can remove the udev rules and to get settings taken from ifcfg scripts.

cipher  ~  sudo rm /etc/udev/rules.d/70-persistent.rules

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

cipher  ~  sudo systemctl mask NetworkManager

cipher  ~  sudo systectl stop networkManager 

cipher  ~  sudo systemctl restart network 

3.Creating a new virsh network using virsh-define with a custom gateway ip address

  

cipher  ~  virsh net-list

Name State Autostart Persistent
----------------------------------------------------------
cipher-nat1 active yes yes
cipher-nat2 active yes yes
cipher-nat3 active yes yes
default active yes yes
docker-machines active yes yes

Stop the network , make configuration changes then start it.

cipher  ~  virsh net-destroy cipher-nat2
Network cipher-nat2 destroyed

cipher  ~  virsh net-edit cipher-nat2

  cipher-nat2
  b47815b6-9f2d-4dcb-8ddf-bebddb5c969d
  
cipher  ~  virsh net-start cipher-nat2
Network cipher-nat2 started

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