I am experiencing some interesting problems creating a VM from a raw img file. This is the Mikrotik Cloud Hosted Router (CHR) Image downloaded directly from Mikrotik download site. I tried following standard import procedures both from the web gui and using the migration tool, but something is failing, so here I am
Image settings: This image does not support UEFI boot and secure boot, so I add the following configurations to my LXD VM yaml:
security.csm: 'true'
security.secureboot: 'false'
What works
If I download and import CHR version 6 as a LXD VM, I can get a VM running, no problem. However my NICs are then not found within the OS because CHR6 does not support virtio drivers.
If I download and import CHR version 6 or 7 to a QEMU-KVM hypervisor, both versions of the OS boot using legacy bios without issues.
What does not work
If I download and import CHR version 7 using LXD GUI, the import procedure fails with this error:
Error transferring instance data: Failed conversion on target: Failed creating instance on target: Failed to run: /snap/lxd/33085/bin/sgdisk --move-second-header /dev/zvol/lxd-pool/virtual-machines/chr.block: exit status 2 (Invalid partition data!)
Same error happens if I manually download the lxd-migrate tool and run it on the host.
I spoke with the folks at Mikrotik and they explained how the CHR image works. Basically it is a raw disk image with a filesystem and no GPT nor boot loader structure. and sgdisk does not like that.
I think with that info, I have a path forward. I will try and build LXD images with CHR and see if I can make it work that way.
I managed to work around this problem using LXD 6.3 snap on Ubuntu 24.04.
I manually created an instance and cloned the raw image directly into the VM’s block storage. I leave some instructions here in case someone faces a similar issue importing VMs in LXD.
Download the Mikrotik CHR raw disk image
From the Download page, search for Cloud Hosted Router (CHR) and download lastest stable raw image 7.18.2 https://mikrotik.com/download. Unzip the image and you should have this file: chr-7.18.2.img