aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Luis Duran <jlduran@FreeBSD.org>2026-05-27 00:22:39 +0000
committerJose Luis Duran <jlduran@FreeBSD.org>2026-05-27 00:22:39 +0000
commit87150a2ed140d5a3c1272ce9cfe815f19282840b (patch)
tree005c134357d2f4340cd2925e2b3ab8144902e08b
parent318a85d4b201b1cb77f25c8a98d2b0687e8259e5 (diff)
nanobsd: Refactor secondary code partition logic
Rearrange the conditional logic for building the secondary code slice (altroot). Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D57223
-rw-r--r--tools/tools/nanobsd/legacy.sh37
1 files changed, 19 insertions, 18 deletions
diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh
index 1d7a0cef2fed..52d60b4fda8c 100644
--- a/tools/tools/nanobsd/legacy.sh
+++ b/tools/tools/nanobsd/legacy.sh
@@ -308,28 +308,29 @@ _create_diskimage() {
diskimage="-p freebsd:=${NANO_DISKIMGDIR}/${NANO_IMG1NAME}:$(( NANO_SECTS * 512 ))"
- if [ "$NANO_IMAGES" -gt 1 ] && [ "$NANO_INIT_IMG2" -gt 0 ] ; then
- echo "Duplicating to second image..."
- tgt_switch_root_fstab "${NANO_SLICE_ROOT}" "${NANO_SLICE_ALTROOT}"
- nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
- "${NANO_METALOG}" "$(( CODE_SIZE - METADATA_SECTS ))" \
- "${NANO_OBJ}/_.altroot.part" "${NANO_WORLDDIR}"
- tgt_switch_root_fstab "${NANO_SLICE_ALTROOT}" "${NANO_SLICE_ROOT}"
- if [ -f "${NANO_WORLDDIR}/boot/boot" ]; then
- bootcode="-b ${NANO_WORLDDIR}/boot/boot"
+ if [ "$NANO_IMAGES" -gt 1 ] ; then
+ if [ "$NANO_INIT_IMG2" -gt 0 ] ; then
+ echo "Duplicating to second image..."
+ tgt_switch_root_fstab "${NANO_SLICE_ROOT}" "${NANO_SLICE_ALTROOT}"
+ nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
+ "${NANO_METALOG}" "$(( CODE_SIZE - METADATA_SECTS ))" \
+ "${NANO_OBJ}/_.altroot.part" "${NANO_WORLDDIR}"
+ tgt_switch_root_fstab "${NANO_SLICE_ALTROOT}" "${NANO_SLICE_ROOT}"
+ if [ -f "${NANO_WORLDDIR}/boot/boot" ]; then
+ bootcode="-b ${NANO_WORLDDIR}/boot/boot"
+ fi
+ mkimg -s bsd -S 512 --capacity $(( CODE_SIZE * 512 )) \
+ ${bootcode} \
+ -p freebsd-ufs:="${NANO_OBJ}/_.altroot.part" \
+ -o "${NANO_OBJ}/_.altroot.image"
+ altroot="-p freebsd:=${NANO_OBJ}/_.altroot.image:+$(( NANO_SECTS * 512 ))"
+ rm -f "${NANO_OBJ}/_.altroot.part"
+ else
+ altroot="-p freebsd::${CODE_SIZE}b:+$(( NANO_SECTS * 512 ))"
fi
- mkimg -s bsd -S 512 --capacity $(( CODE_SIZE * 512 )) \
- ${bootcode} \
- -p freebsd-ufs:="${NANO_OBJ}/_.altroot.part" \
- -o "${NANO_OBJ}/_.altroot.image"
- altroot="-p freebsd:=${NANO_OBJ}/_.altroot.image:+$(( NANO_SECTS * 512 ))"
- rm -f "${NANO_OBJ}/_.altroot.part"
else
altroot="-p-"
fi
- if [ "${NANO_INIT_IMG2}" -eq 0 ]; then
- altroot="-p freebsd::${CODE_SIZE}b:+$(( NANO_SECTS * 512 ))"
- fi
# Create Config slice
_populate_cfg_part "${NANO_OBJ}/_.cfg.part" "${NANO_CFGDIR}" \