Is it possible to take an Incus VM (Linux VM) and export a raw disk image to be restored to a physical machine? In short, incus-migrate allows taking a raw, qcow2, or vmdk image and creating an incus VM from it. Is there a “V to P” which would allow an incus virtual machine to be exported to a raw image which in turn could be restored to a physical hard drive using “dd” and then become bootable?
I have a lab use case where I want to image a physical machine and import it to an incus VM. I think that part is pretty straight forward. I want to then work with the incus VM and at some point export it to a raw image to write back to the physical disk on a bare metal machine. Any ideas?
Inside the tarfile you’ll find backup/virtual-machine.img which is the raw image.
(The image in the tarball is not sparse, so after extracting it you might want to gzip it before copying to the remote system, or pass it through dd conv=sparse)
It’s also possible to publish a VM as an image and then export that image. In that case, the image export contains rootfs.img, which is actually a qcow2 file not a raw image.
The “publish” option sounds awesome. I don’t know why that had not occurred to me since I have published dozens of container images. Can you expound on what the “conv=sparse” means?
A sparse file is one where blocks containing all zeros are not allocated. That is, you can have a file whose “size” is say 10GiB, but which consumes much less than that (as reported by du or ls -s).
Alternatively, you could gzip it, which is a safer thing to do if you’re planning to copy the file to another system.
tar -Oxzf /var/tmp/blah.tar.gz backup/virtual-machine.img | gzip >/var/tmp/nsrc-nmm.raw.gz
@candlerb I see… as in the idea of a fixed disk allocation vs. a dynamic disk allocation. My use case for all of this is I have a couple bare metal machines running Ubuntu 22.04. When I attempt the standard upgrade to 24.04, the system locks up/freezes immediately after the prompt as to if I want to replace system.conf. I have pulled all my nvidia drivers and even tried to do the upgrade from both the console and an ssh session. I have a very complex configuration that I truly want to upgrade and not just copy files over. I image the entire drive with redo rescue and make an attempt at the upgrade. Once the lockup happens, the system is so badly damaged it just can’t be fixed. I then restore the backup image and it is back working 100%. My thought is to create a raw dd image of the system and import it to an incus vm and try the upgrade from there. If successful, I can image the results and restore the image to bare metal. Trust me when I say that I am at attempt six now and I have spent as long as 19 hours straight trying to debug what happened and how to continue the upgrade with no success. The system in question began in 2007 under Ubuntu 7.04 and has been upgraded since successfully each time and runs rock solid no errors under Ubuntu 22.04. During my travels from back in 2007, my upgrades even consisted of converting the file system from ext-3 to ext-4, changing from FAT/MBR to GUID/EFI and changing out many, many motherboards along the way. At this point, its a quest for me to figure out what’s breaking.
Good luck with the upgrade. The other approach to consider is to back up the whole system to an external disk, install Ubuntu 24.04 from fresh, and then copy back your applications and configs. Sometimes it’s a good idea to do a spring clean
If I have almost 20 years worth of very precise, technical, and detailed configuration, then a fresh install and just copying my files is sooooooooooo much the Microsoft Windows approach which made me run from Windows in 2007. The important thing to understand is that data and applications are easy to restore. The extremely detailed configuration of almost 200 applications I use is not easy to restore. An example might be incus or OBS. Sometimes years of customization goes into the ideal desktop. Restoring the data and the apps does nothing to restore all the work that went into making the desktop and its applications what works for the user.