There seems to have been many changes from 12.2 to 12.3 in /usr/src/tools/tools/nanobsd for some reason I end up with a disk image with root on s1, /cfg on s2 and nothing on s3 this have not been a problem on 12.2, but I assume its a problem due to I have "NANO_IMAGES=1" in my .conf file expected behaviour: s1 for root, s2 preserved as a blank, and s3 used for /cfg actually getting: s1 for root, s2 used for /cfg, s3 blank result: Image can't boot... it expect /cfg on s3
I have the same issue on FreeBSD 12.3, 13.0 and 13.1, on i386 architecture. I've also tried the complete example from this page (using NANO_IMAGES=1): https://docs.freebsd.org/en/articles/nanobsd/ More info from nanobsd log: newfs -b 4096 -f 512 -i 8192 -U -Lnanobsds3 /dev/md0s3 newfs: /dev/md0s3: could not find special device Running exit trap code
Created attachment 255380 [details] nanobsd: Always account for 2 code partitions I was able to replicate this bug. The attached patch (not the final patch, just the shortest fix) should fix the issue. What throws me off is that I was not able to find a difference between 12.2 and 12.3. So there might be something else. The patch always reserves the partition for code#2, it is not populated if NANO_IMAGES=1 or NANO_INIT_IMG2=0. Thanks for reporting it, if it is still within your possibilities I would appreciate it if you could test it.
Created attachment 255516 [details] nanobsd: Always define the partition index Print the partition index together with the starting sector and the size in sectors. Otherwise, when only one code partition is desired, the configuration partition (/cfg) may not end in the third slice, and breaking the scripts that expect it there. Prefer this approach rather than adjusting the scripts dynamically to avoid a breaking change.
Hello, Thanks for your patch, it does work on FreeBSD 14.2-RELEASE! I hope it'll be merged soon.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=dc4b36b96333f2ab05f3c454f0df2e0a0d4d451d commit dc4b36b96333f2ab05f3c454f0df2e0a0d4d451d Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-02-04 14:07:00 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-02-04 14:07:00 +0000 nanobsd: Always define the partition index Print the desired partition index together with the starting LBA and the size. Otherwise, when only one code partition is desired, the configuration partition (/cfg) may not end up in the third slice, thus breaking the scripts that expect it there. This was the previous approach, changed in 587c054bea0f ("nanobsd: Use gpart and create code image before full disk image"). Fix it by printing the index as the last column to reduce the chances of breaking current overrides, and using it as the gpart index. PR: 262098 Reviewed by: imp Approved by: emaste (mentor) Fixes: 587c054bea0f ("nanobsd: Use gpart and create code image before full disk image") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47835 tools/tools/nanobsd/legacy.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=e58d9b71f37dde1cd19bb0af3a4bf94938f4406d commit e58d9b71f37dde1cd19bb0af3a4bf94938f4406d Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-02-04 14:07:00 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-02-12 01:32:12 +0000 nanobsd: Always define the partition index Print the desired partition index together with the starting LBA and the size. Otherwise, when only one code partition is desired, the configuration partition (/cfg) may not end up in the third slice, thus breaking the scripts that expect it there. This was the previous approach, changed in 587c054bea0f ("nanobsd: Use gpart and create code image before full disk image"). Fix it by printing the index as the last column to reduce the chances of breaking current overrides, and using it as the gpart index. PR: 262098 Reviewed by: imp Approved by: emaste (mentor) Fixes: 587c054bea0f ("nanobsd: Use gpart and create code image before full disk image") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47835 (cherry picked from commit dc4b36b96333f2ab05f3c454f0df2e0a0d4d451d) tools/tools/nanobsd/legacy.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=6fc8d02b59dd7c343a2ab681e57c13c27c6425f7 commit 6fc8d02b59dd7c343a2ab681e57c13c27c6425f7 Author: Jose Luis Duran <jlduran@FreeBSD.org> AuthorDate: 2025-02-04 14:07:00 +0000 Commit: Jose Luis Duran <jlduran@FreeBSD.org> CommitDate: 2025-02-12 01:38:47 +0000 nanobsd: Always define the partition index Print the desired partition index together with the starting LBA and the size. Otherwise, when only one code partition is desired, the configuration partition (/cfg) may not end up in the third slice, thus breaking the scripts that expect it there. This was the previous approach, changed in 587c054bea0f ("nanobsd: Use gpart and create code image before full disk image"). Fix it by printing the index as the last column to reduce the chances of breaking current overrides, and using it as the gpart index. PR: 262098 Reviewed by: imp Approved by: emaste (mentor) Fixes: 587c054bea0f ("nanobsd: Use gpart and create code image before full disk image") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47835 (cherry picked from commit dc4b36b96333f2ab05f3c454f0df2e0a0d4d451d) tools/tools/nanobsd/legacy.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)