Introduction

I recently migrated my homelab servers from running bare metal KVM/QEMU on Ubuntu, to running Proxmox as a hypervisor. As part of that process I migrated some of the VM's from KVM to Proxmox. In this post I will show you how I imported the qcow2 VM's from KVM/QEMU into Proxmox.

The following software was used in this post.

  • Proxmox - 7.0-11
  • Ubuntu - 18.04

KVM/QEMU Host

Start by finding the ID of the VM you want to migrate.

cmd

virsh list --all

# Output
 Id    Name                           State
----------------------------------------------------
 2     uctl01                         running
    

Shutdown the target VM.

cmd

virsh shutdown 2

# Output
 Id    Name                           State
----------------------------------------------------
       uctl01                         shut off
    

Copy the qcow2 image to the Proxmox host. I used SCP in the below example.

cmd

scp /opt/libvirt/vm/uctl01.qcow2 root@<target-ip>:/tmp/uctl01.qcow2
    

That's everything that is required on the KVM/QEMU host.

Proxmox Host

On the Proxmox host, create a new VM that will be used to attach the qcow2 disk that was copied over. Ensure that you use a unique VM ID: 101 in the below example.

cmd

qm create 101 \
  --name uctl01 --numa 0 --ostype l26 \
  --cpu cputype=host --cores 2 --sockets 1 \
  --memory 4096  \
  --scsihw virtio-scsi-pci \
  --net0 bridge=vmbr0,virtio=BE:66:BD:74:E8:C9,firewall=1 \
  --serial0 socket
    

Confirm the VM was created successfully.

cmd

qm list 

# Output
VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID
 101 uctl01               stopped    4096               0.00 0
    

Import the qcow2 disk to the required datastore. local-lvm in my case.

cmd

qm importdisk 101 /tmp/uctl01.qcow2 local-lvm

# Output
Successfully imported disk as 'unused0:local-lvm:vm-101-disk-0'
    

Attach the disk to the VM created in the previous step.

cmd

qm set 101 --scsi0 local-lvm:vm-101-disk-0

# Output
update VM 101: -scsi0 local-lvm:vm-101-disk-0
    

Make the disk bootable, otherwise the VM will not boot.

cmd

qm set 101 --boot c --bootdisk scsi0

# Output
update VM 101: -boot c -bootdisk scsi0
    

Thats all the steps required to import the VM into the Proxmox host. But we are not finished yet, the VM had no network connectivity 😭.

Virtual Machine

When I built the VM on the KVM host, the network interface was named ens3. When I imported it into Proxmox, the interface named changed to ens18. The interface name needs to be updated in netplan.

Logon to the console of the VM to update the network interface numbering.

cmd

qm terminal 101

# Output
starting serial terminal on interface serial0 (press Ctrl+O to exit)

# Login with username/password
    

Confirm the network interface numbering.

cmd

ip addr

# Output
2: ens18:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
...
    

Update the /etc/netplan/01-netcfg.yaml config file.

file

# /etc/netplan/01-netcfg.yaml
network:
  version: 2
  ethernets:
    # ens3: <- Change to current interface name
    ens18:
      dhcp4: no
      dhcp6: no
      addresses: [<ip-address>/<prefix-length>]
      gateway4: <gateway-ip-address>
      nameservers:
        addresses: [<nameserver-ip-address>]
    

Apply the netplan config.

cmd

sudo netplan apply
    

And that's it, the VM should now have network connectivity.

Summary

In this post, I showed you how to import a QCOW2 VM from a KVM/QEMU host to a Proxmox host and update the network settings on the VM to fix network connectivity.

Tags

proxmox linux