hashicorp / hashicorp/packer-plugin-vagrant

post-processor: create disk image without a backing file

Open
#44 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
16
Forks
28
PR merge metrics
No merged PRs in 30d

Description

#### Description

When using a backing file like:

```hcl
source "qemu" "packer-qemu-ansible-debian-example" {
...
disk_image = true
use_backing_file = true
iso_url = "/home/rgl/.vagrant.d/boxes/debian-11-amd64/0/libvirt/box.img"
}

build {
...
post-processor "vagrant" {
output = "packer-qemu-ansible-debian-example.box"
}
}
```

The disk image inside the generated vagrant box is using a backing file:

```console
$ qemu-img info ~/.vagrant.d/boxes/packer-qemu-ansible-debian-example/0/libvirt/box.img
image: /home/rgl/.vagrant.d/boxes/packer-qemu-ansible-debian-example/0/libvirt/box.img
file format: qcow2
virtual size: 60 GiB (64424509440 bytes)
disk size: 139 MiB
cluster_size: 65536
backing file: /home/rgl/.vagrant.d/boxes/debian-11-amd64/0/libvirt/box.img
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
```

This makes the box depend on that backing file, which is not what I would expect. I was expecting an stand-alone disk inside the box file.

Creating a stand-alone disk is a matter of executing qemu-img ([instead of just copying the img](https://github.com/hashicorp/packer-plugin-vagrant/blob/e3b4ec6848cd391c93f93041d354960565c299e8/post-processor/vagrant/libvirt.go#L72-L76)) with something alike:

```bash
qemu-img convert -O qcow2 with-backing-file.img standalone.img
```

What do you think? Would a PR with this be acceptable?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.