Importing KVM Servers
Introduction
Although no import methods exist yet from competing virtualization solutions, it's still possible to migrate data in to VirtFusion.
VirtFusion uses the industry standard cloud-init and guest agent (if available) to provision and manage virtual servers, however a large portion of competing products use invasive methods at hypervisor level to achieve the same result. This means virtual servers imported in to VirtFusion will need extra packages if you want to take full control.
This guide will help you install those dependencies and move virtual disks in to VirtFusion.
This guide presumes you are migrating virtual machines from an existing hypervisor with virtual machines to a newly installed VirtFusion hypervisor.
Disk Preparation
Disks come in all shapes, sizes and locations and differ in type (qcow2, raw and LVM).
Dependant on the software you are using, the location of the disk could be anywhere on the hypervisor filesystem, you'll need to find the location of the disk before you can continue.
ALL DISK ACTIONS SHOULD BE COMPLETED WITH THE VIRTUAL SERVER IN AN OFFLINE STATE.
One of the most important parts of migrating a disk, is making sure you know the size and type of the disk you are going to import. If you don't do this, it may cause data corruption and inaccurate statistics in Virtfusion.
LVM
If your disks are stored in logical volumes, you will need to convert them to images. You can convert to disk images easily using the following commands:
/dev/vg_name/lv_name
should be the path to the volume that contains the virtual server data and /path/to/disk.img
will be the output disk image.
Convert to Qcow2 Image
qemu-img convert -O qcow2 /dev/vg_name/lv_name /path/to/disk.img
Convert to Raw Image
qemu-img convert -O raw /dev/vg_name/lv_name /path/to/disk.img
Disk Images
Find the Type and Size
If the disk is an image (qcow2/raw) or you have converted from LVM, you can easily reference the size and type using the following command:
qemu-img info /path/to/disk.img
Example output for a raw
disk:
image: disk.img
file format: raw
virtual size: 10 GiB (10737418240 bytes)
disk size: 4 KiB
Example output for a qcow2
disk:
image: disk.img
file format: qcow2
virtual size: 10 GiB (10737418240 bytes)
disk size: 2.12 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
refcount bits: 16
corrupt: false
extended l2: false
The two important fields are file format
(disk type) and virtual size
(disk size).
Convert
VirtFusion defaults to qcow2
as it's storage type but also supports raw
images. If the disk is not in the correct format, you can convert it easily.
The following commands will produce a copy of the original disk called new_disk.img
.
Raw to Qcow2
qemu-img convert -f raw -O qcow2 /path/to/disk.img /path/to/new_disk.img
Qcow2 to Raw
qemu-img convert -f qcow2 -O raw /path/to/disk.img /path/to/new_disk.img
Networking
This part can get a little messy due to how some competing products create network configurations within a virtual server. If you would like VirtFusion to take full control of networking, you will need to make sure network configurations are correct.
Interface Naming
Predictable Network Interface Device Names
may have been disabled, i.e net.ifnames=0
and biosdevname=0
on the kernel command line in /etc/grub.conf
. This can cause issues with cloud-init configuration where it expects predictable naming. This can mostly be resolved by setting an interface name in VirtFusion Server -> Network -> Interface Name
and is explained in a later step.
Debian Interface File
Debian uses /etc/network/interfaces
for network configuration. Sometimes this configuration will be hard coded and will not contain the correct include paths for cloud-init. This can be resolved by making sure only the following contents are in /etc/network/interfaces
:
source /etc/network/interfaces.d/*
Install Cloud-Init & Guest Agent
It's wise to install cloud-init and the guest agent if possible. The following commands may not work on all disks and depend on the operating system installed on the disk.
Once you have completed this step, you should not boot the disk image until it has been imported into VirtFusion.
virt-customize -a /path/to/disk.img --install cloud-init,qemu-guest-agent
If you would prefer to install both these applications manually, you may do so using the stock distribution tools (apt, yum, dnf etc...).
Windows does not use the Cloud-Init package directly, and uses a solution called Cloudbase-Init which can be downloaded directly from here in MSI format. For guest agent installation, you can download the latest version here in MSI format.