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 587c054bea ("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:	587c054bea ("nanobsd: Use gpart and create code image before full disk image")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47835
This commit is contained in:
Jose Luis Duran 2025-02-04 14:07:00 +00:00
parent da1deb784d
commit dc4b36b963
No known key found for this signature in database
GPG key ID: 5415E244477475CC

View file

@ -64,31 +64,30 @@ calculate_partitioning ( ) (
}
# First image partition start at second track
print $3, isl * cs - $3
print $3, isl * cs - $3, 1
c = isl * cs;
# Second image partition (if any) also starts offset one
# track to keep them identical.
if ($2 > 1) {
print $3 + c, isl * cs - $3
print $3 + c, isl * cs - $3, 2
c += isl * cs;
}
# Config partition starts at cylinder boundary.
print c, csl * cs
print c, csl * cs, 3
c += csl * cs
# Data partition (if any) starts at cylinder boundary.
if ($7 > 0) {
print c, dsl * cs
print c, dsl * cs, 4
} else if ($7 < 0 && $1 > c) {
print c, $1 - c
print c, $1 - c, 4
} else if ($1 < c) {
print "Disk space overcommitted by", \
c - $1, "sectors" > "/dev/stderr"
exit 2
}
}
' > ${NANO_LOG}/_.partitioning
)
@ -174,7 +173,7 @@ create_diskimage ( ) (
}
{
# Make partition
print "gpart add -t freebsd -b ", $1, " -s ", $2, " $1"
print "gpart add -t freebsd -b ", $1, " -s ", $2, " -i ", $3, " $1"
}
END {
# Force slice 1 to be marked active. This is necessary