freebsd / poudriere

Port/Package build and test system
https://github.com/freebsd/poudriere/wiki
BSD 2-Clause "Simplified" License
389 stars 161 forks source link

poudriere image fails with error from mkimg #1098

Closed einsibjarni closed 9 months ago

einsibjarni commented 9 months ago

Prerequisites

Describe the bug

After upgrading the host to 14.0-RELEASE (and now on 14.0-RELEASE-p2) poudriere image ... -t zfs+gpt ... fails with:

mkimg: partition 2: Invalid argument

How to reproduce

Steps to reproduce the behavior:

Run poudriere image -v -j 132amd64 -p 132amd64_default -z default -n template -h freebsd-template -s 3g -t zfs+gpt -f /usr/local/etc/poudriere.d/buildlists/132amd64

Expected behavior

A working image is created

Screenshots

## Environment - Host OS [e.g. 12.2 amd64]: 14.0-RELEASE-p2 - Jail OS [e.g. 12.0 powerpc]: 13.2-RELEASE-p7 - Browser: [e.g. chrome, safari]: - Poudriere Version [e.g. 3.3.1 or git hash or port version]: 3.4.99.20231113 - Ports branch and revision [e.g. 2020Q3 r550754]: ## Additional context The problem is in https://github.com/freebsd/poudriere/blob/9143ab494773f7a1ba69efc31177d4bbfe51bf7f/src/share/poudriere/image_zfs.sh#L172 If I change the line to ``` gptboot="-p freebsd-boot:=${mnt}/boot/gptzfsboot" ``` The error dissapears, but the image is not valid and will not boot. Reading `mkimg` usage instructions and git commit messages, I've tried multiple different versions of the command "-p freebsd-boot:=${mnt}/boot/gptzfsboot::512k" etc. Looking at `mkimg` output on 13.2-RELEASE-p5, I can't see that the current version of the code could ever have worked... ``` partition specification: [/]::[:[+]] - empty partition of given size and optional relative or absolute offset [/]:=[:[+]offset] - partition content and size are determined by the named file and optional relative or absolute offset [/]:- - partition content and size are taken from the output of the command to run - - unused partition entry where: - scheme neutral partition type - optional scheme-dependent partition label ```
einsibjarni commented 9 months ago

If I change the line to gptboot="-p freebsd-boot:=${mnt}/boot/gptzfsboot" AND set zpool -o compatibility=openzfs-2.1-freebsd, I can boot the image in BIOS mode. It won't boot in UEFI.

jlduran commented 9 months ago

The problem with that change is that it would create a freebsd-boot partition the size of /boot/gptzfsboot(~173K), and we want it to be 512K (to keep it inline with bsdinstall). Regarding the EFI boot, I was able to boot without problems, with an image that has the same zpool version/features as the builder. Base releases use makefs -t zfs to overcome this issue (among other things).

jlduran commented 9 months ago

Apparently #962 (taken from #958) never fixed the issue, just avoided a failed assertion. Would you mind trying with:

truncate -s 512k ${mnt}/boot/gptzfsboot
gptboot="-p freebsd-boot:=${mnt}/boot/gptzfsboot"
jlduran commented 9 months ago

Waiting on feedback from @einsibjarni before submitting. Possible patch, if OK (https://github.com/jlduran/poudriere/commit/4f33a15924df67ef9bdb8b84fc442940196067c1). (Only tested with sh /usr/share/examples/bhyve/vmrun.sh -u -m 4G -t tap0 -d /usr/local/etc/poudriere.d/buildlists/132amd64 132amd64, with and without -E for EFI booting).

einsibjarni commented 9 months ago

Tested https://github.com/jlduran/poudriere/commit/4f33a15924df67ef9bdb8b84fc442940196067c1 and it fixed the problem. Booted without problems with EFI

jlduran commented 9 months ago

@einsibjarni thank you! I’ll proceed with the fix.