We have been testing lxd at work and between lxd and ansible we have been able to create workflows that are the same for both containers and virtual machines. The company is investing in vmware for its integration with other products we require and we maintain a significant number of qemu based systems that are not going away any time soon.
Q: How can we use the same workflows and vm images to create QEMU and vmware native systems? I realize I could just stick an iso in and rebuild the whole thing but we like the way LXD lets us work and are a lean team with less resources than this would require.
When you export a VM to a non-optimised tarball file, inside there is the VM’s root disk file.
It is in raw format, so if you can find a tool to convert that to the required format of your target system then that should be possible.
Ok so based on what I read and what you just suggested I am trying the following.
# lxc export isg-mon-02 -v --compression gzip --instance-only isg-lxd-vm.tgz
# tar -tzvf isg-lxd-vm.tgz
# tar -xzvf isg-lxd-vm.tgz backup/virtual-machine.img
# losetup -f backup/virtual-machine.img
# fdisk -lu /dev/loop6
Disk /dev/loop6: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 39F8B3E1-F4C8-40B0-9148-CF49523F0BAA
Device Start End Sectors Size Type
/dev/loop6p1 2048 206847 204800 100M EFI System
/dev/loop6p2 206848 20971486 20764639 9.9G Linux filesystem
Which looks right and which I can convert to qcow2.
qemu-img convert -f raw -O qcow2 backup/virtual-machine.img vm_hdd.qcow2
But which doesn’t boot out of the box.
Is it worth looking at the other data to configure qemu appropriately (cpu type, devices where the os expects them etc)? Or should I just futz with it until I get a configuration that works?
Also is this something we can expect to not change without notice?
It takes a while de/compressing the image. Exporting it without compressing it saved me a significant amount of time, for example: lxc export win11 -v --compression none win11-lxd.tgz
Then export it with:
tar -xvf win11-lxd.tgz backup/virtual-machine.img