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

qemu builder - mount iso as disk, not cdrom

Open ghost opened this issue 3 years ago • 1 comments

This issue was originally opened by @mxl as hashicorp/packer#4774. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


I'm trying to build macOS image with qemu builder. The problem is that I have not found the way to create macOS (Sierra 10.12.3) ISO that is recognized by qemu when mounted with -cdrom option. I used this script from kholia/OSX-KVM and read few other tutorials which use the same way to create ISO image, but they use the following qemu options to mount image:

-device ide-drive,bus=ide.0,drive=MacDVD \
-drive id=MacDVD,if=none,snapshot=on,file=./'Install_macOS_Sierra_(OS_X_10.12).iso'

If I add similar options to qemuargs:

[ "-drive", "if=ide,snapshot=on,file={{ user `iso_url` }}" ]

then image is recognized and booted but it seems that packer thinks that I try to override -drive option used to attach main image and it creates output-qemu/packer-qemu image but does not attach it so I have to do it manually:

[ "-drive", "file=output-qemu/packer-qemu,if=ide,cache=writeback,discard=ignore,format=qcow2"]

From qemu documentation:

Instead of -cdrom you can use:

qemu-system-i386 -drive file=file,index=2,media=cdrom

It would be useful if we could change media parameter of qemu -drive option. E.g. packer could have iso_media parameter what by default has cdrom value but also can be disk and iso_interface parameter will specify the interface to use for the drive where image attached.

ghost avatar Apr 19 '21 16:04 ghost

I am going to take a crack at fixing this. Easiest implementation is to add a new field called additional_iso_mounts which just mounts a cdrom device into QEMU. This could potentially steal some code from go getter to allow a second iso to be downloaded. Any thoughts on this approach?

aidanleuck avatar Aug 02 '24 20:08 aidanleuck