Edit: Just had a thought, no idea if it's another potential workaround. In the builder you specify a template to clone that is used to create the VM. I'm on Xenserver 8, and there is no way through the GUI, but I think it might be possible to add an extra DVD-drive to a template? If that gets brought over to the packer vm, then that might be an option. Might need to do an eject from within the vm in order to dismount the dvd in order to not have it be part of the artifact though.
@olivierlambert Sounds like the best way forward would be to add the equivalent of the Hyper-V builder's secondary_iso that mounts a second iso-file, or even better cd_files which creates a temporary iso for you and mounts it.
For anyone who wants to test building eufi machines until this is solved, I have a Powershell script that takes a Windows ISO and generates a new one with files added (in my case autounattend.xml, bootstrap.ps1 and the management agent msi. Though I should change it to just download the msi instead to avoid rebuilding it.)
Since I was building a new ISO anyway, I also changed the boot loader to the noprompt one in order to avoid the timing issues with boot_commands and "Press any key to boot from DVD...."
The script uses oscdimg.exe that's included in the Windows ADK, which can be found here:
https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install
# Settings
$Architecture = "amd64" # Or x86
$InputISOfile = "D:\Deploy\ISO\Windows Server 2022 Eval.iso"
$OutputISOfile = "D:\Deploy\ISO\Windows Server 2022 Eval XenServer.iso"
$TempFolder = "E:\Temp\Win2022XenServer"
$AdditionalFiles = @(
"C:\files\Autounattend.xml",
"C:\files\bootstrap.ps1",
"C:\\managementagentx64.msi"
)
$OSCDIMG_Path = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools" + "\$Architecture\Oscdimg"
# Check environment
If (!(Test-path $InputISOfile)){ Write-Warning "Input ISO file not found. Exiting";Break}
If (!(Test-path $OSCDIMG_Path)){ Write-Warning "OSCDIMG Path not found. Exiting";Break}
if((Test-Path $TempFolder)){ Write-Warning "Temp folder $TempFolder exists. Exiting.";Break}
foreach($file in $AdditionalFiles) {
if(!(Test-Path $$file)){ Write-Warning "Additional file $file does not exists. Exiting.";Break}
}
# Mount the original Windows ISO and figure out the drive-letter
Mount-DiskImage -ImagePath $InputISOfile
$ISOImage = Get-DiskImage -ImagePath $InputISOfile | Get-Volume
$ISODrive = [string]$ISOImage.DriveLetter+":"
# Copy ISO contents to temp dir and add additional files
New-Item -Path $TempFolder -ItemType Directory -Force
Copy-Item "$ISODrive\*" $TempFolder -Recurse
if(($AdditionalFiles) -and $AdditionalFiles.Length -gt 0) {
Copy-Item $AdditionalFiles $TempFolder
}
# Dismount the Original ISO
Dismount-DiskImage -ImagePath $InputISOfile
# Create a new bootable Windows ISO file, based on the Original ISO, but using efisys_noprompt.bin instead
$BootData='2#p0,e,b"{0}"#pEF,e,b"{1}"' -f "$TempFolder\boot\etfsboot.com","$TempFolder\efi\microsoft\boot\efisys_noprompt.bin"
$Proc = Start-Process -FilePath "$OSCDIMG_Path\oscdimg.exe" -ArgumentList @("-m","-o","-bootdata:$BootData",'-u2','-udfver102',"$TempFolder\","`"$OutputISOfile`"") -PassThru -Wait -NoNewWindow
if($Proc.ExitCode -ne 0)
{
Throw "Failed to generate ISO with exitcode: $($Proc.ExitCode)"
}
Get-FileHash -Path $OutputISOfile -Algorithm SHA256
Remove-Item $TempFolder -recurse -force