VM converter
A tool for converting between vmware and kvm formats using qemu-img
Why
Moving supervisors is possible, but anoying. What you have to do is
- Move the files
- Use qemu-img to convert between .vmdk and .qcow2
- Write a new VM config file for the hypervisor you will be using
- Register the VM in the hypervisor interface
This tool aims to simplify this process using a web interface and automation.
How
The setup will consist of a few different parts:
- Esxi host
- Proxmox host
- Frontend in Vue
- Backend
- SSH keys
The SSH keys are used for SCP transfers. They are generated with ssh-keygen:
ssh-keygen -t rsa -b 8192 -f ~/.ssh/id_rsa -N ""
The key is then added to the proxmox nodes using the following command:
sshpass -p Monster123 ssh-copy-id -o StrictHostKeychecking=no -i ~/.ssh/id_rsa.pub root@192.168.10.41
And for esxi nodes we download the existing key from the server:
sshpass -p Monster123! scp -o StrictHostKeychecking=no ~/.ssh/id_rsa.pub root@192.168.10.52:/etc/ssh/keys-root/authorized_keys
The backend needs the following tools
- Nodejs with web API
- ssh for file transfer
- Powershell with PowerCLI for interacting with esxi
- qemu-img for converting disk formats
it is distributed as a docker container to keep setup complexity down.
To migrate a vm from esxi to proxmox:
- PowerCLI gets the VM listing, datastore and directory
- Stop the VM
- Move the VM to the server for conversion using SCP
- Convert .vmdk to .qcow2 using qemu-img
- Convert vmware .vmx to kvm .conf using custom tool
- Register the VM using proxmox API
- Start the VM
Scp command:
scp -rB3 root@192.168.10.52:/vmfs/volumes/ssd3/tailscale-home root@192.168.10.41:/root/tailscale-home
Adding the C
flag for compression may reduce transfer time over WAN, but it is left out since it is not able to achieve 1 gbps.
Image conversion command:
qemu-img convert -f vmdk windows_xp_64/windows_xp_64.vmdk -O qcow2 /var/lib/vz/images/102/windows_xp_64.qcow2
Config files
On kvm:
/etc/pve/local/qemu-server/100.conf