packer-plugin-qemu icon indicating copy to clipboard operation
packer-plugin-qemu copied to clipboard

Allow compressing images with backing files

Open darius-m opened this issue 4 years ago • 0 comments

Please search the existing issues for relevant feature requests, and use the reaction feature (https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

The qemu-img tool is able to compress or convert images that have a backing file, by appending the -B backing_file argument to the qemu-img convert command. This allows creating small images for VMs that add incremental changes to the old image when using backing files. Otherwise, the new file can use almost as much space as the backing file after performing simple tasks like updating repositories and installing packages, even if the caches are cleared (the space is not reclaimed).

Use Case(s)

Using as little space as possible when distributing incremental changes to VMs - e.g. having a single base VM and adding minimal configurations for multiple workshops or labs.

Potential configuration

Using the current version of the plugin, the arguments can be added manually to the configuration:

qemu_img_args {
  convert = ["-B", abspath(var.iso_url)]
}

Ideally, this could be used by default when use_backing_file is set to true. The greatest impact can be seen when also using the disk_compression argument.

Potential References

The qemu-img man page.

darius-m avatar Feb 16 '22 12:02 darius-m