There have been times when I found a .ISO of which I’d like to create an LXD container but in the past had to settle for using it to create a KVM VM for the application.
I finally spent some time to create a script which automatically extracts the KVM VM’s rootfs and copies it to an previously created LXD container’s rootfs directory.
So far this seems to work well as I’ve taken various .ISO from both TurnkeyLinux (https://www.turnkeylinux.org/) and Bitnami (https://bitnami.com/stacks), created a KVM VM, then used the script to extract the VM’s rootfs and copy it to an LXD container I’d previously prepared for it. The script hopefully sets the UID/GID in the container correctly for use. I want to thank Stephane Graber for that line in the script which I’d found in an answer he’d posted to someone else in the issues section of the LXD Github.
The script’s process is fairly fast and so far has enabled me to turn up 4-5 LXD containers that originated from an .ISO file. They all seem to work okay from what I can tell.
Hopefully, I’ve documented the convert-vm.sh script enough so that others might improve on it and/or make use of it in the use-cases like I had.
You can find everything on Github at: