The easiest way to create Vagrant boxes on Ubuntu 22.04 is to create them in /tmp directory. As we're already copying QCOW image to vm.qcow2, we could copy the disk image to /tmp/x directory, do the box creation there, and then copy the resulting box back to the original directory.
We should also:
Check the free space in the filesystem providing the /tmp path (hint: shutil.disk_usage) to ensure we don't do something stupid
Use tarfile module to prevent unnecessary copying/renaming of disk images.
The easiest way to create Vagrant boxes on Ubuntu 22.04 is to create them in /tmp directory. As we're already copying QCOW image to vm.qcow2, we could copy the disk image to /tmp/x directory, do the box creation there, and then copy the resulting box back to the original directory.
We should also:
shutil.disk_usage
) to ensure we don't do something stupid