Is it possible to use packer to customize an ISO linux images?

Hello,

I want to customize an Alpine ISO from a ci/cd.

I tried to build an image with packer and qemu plugin.

Build is a success and it generates a raw image (qcow2) in output directory.

I was expecting to be able to copy it to an USB key as easily as it is with an ISO file (ISO 9660).

But I’m stuck…

Should I have to use mkisofs or something else ?

Yes, you can use Packer to customize Linux ISO images, including Alpine Linux. However, Packer typically generates images like qcow2 for virtual environments, not direct bootable ISOs for physical media. To use the qcow2 image on a USB, you’d need to convert it to a raw disk image using a tool like qemu-img and then write it to the USB. Creating a bootable ISO directly from a qcow2 image isn’t straightforward due to format differences, so it’s usually better to customize the ISO before or during the Packer build process if you need a bootable ISO.

Thank you for your help.

I tried to convert the image with this script:

#!/bin/sh
OUTPUT_DIRECTORY=./output-usb_image_installer
qemu-img convert -f qcow2 -O raw ${OUTPUT_DIRECTORY}/usb_image_installer ${OUTPUT_DIRECTORY}/usb_image_installer.img
dd if=${OUTPUT_DIRECTORY}/usb_image_installer.img of=${OUTPUT_DIRECTORY}/usb_image_installer.iso bs=4M

When I try to mount iso file, I have the following error:

sudo mount -o ro,loop output-usb_image_installer/usb_image_installer.iso /media/iso
mount: /media/iso: wrong fs type, bad option, bad superblock on /dev/loop72, missing codepage or helper program, or other error.

I tried to mount the qcow2 fs like this:

$ sudo qemu-nbd --connect=/dev/nbd0 output-usb_image_installer/usb_image_installer  

$ sudo fdisk /dev/nbd0 -l
Disque /dev/nbd0 : 500 MiB, 524288000 octets, 1024000 secteurs
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
$ sudo mount /dev/nbd0p1 /tmp/raw/
mount: /tmp/raw: le périphérique spécial /dev/nbd0p1 n'existe pas.
$ sudo mount /dev/nbd0 /tmp/raw/
mount: /tmp/raw: wrong fs type, bad option, bad superblock on /dev/nbd0, missing codepage or helper program, or other error.

I have this: wrong fs type, bad option, bad superblock on /dev/nbd0, missing codepage or helper program, or other error.

Fixed.
It was not a disk image.
I had to setup alpine the create an UEFI partition.