nanobsd: Account for metadata overhead in code slice
The code slice size (CODE_SIZE) includes 16 sectors reserved for disk metadata (see bsdlabel(8) offset). Subtract these 16 sectors from the total size passed to nano_makefs. This prevents the generated filesystem from consuming the entire slice allocation, ensuring there is enough space for the metadata without overflowing the partition boundary. Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D57220
This commit is contained in:
@@ -31,6 +31,10 @@
|
|||||||
[ -n "$NANO_SECTS" ] || NANO_SECTS=63
|
[ -n "$NANO_SECTS" ] || NANO_SECTS=63
|
||||||
[ -n "$NANO_HEADS" ] || NANO_HEADS=16
|
[ -n "$NANO_HEADS" ] || NANO_HEADS=16
|
||||||
|
|
||||||
|
# The first partition should start at offset 16,
|
||||||
|
# because the first 16 sectors are reserved for metadata.
|
||||||
|
METADATA_SECTS=16
|
||||||
|
|
||||||
# Functions and variable definitions used by the legacy nanobsd
|
# Functions and variable definitions used by the legacy nanobsd
|
||||||
# image building system.
|
# image building system.
|
||||||
|
|
||||||
@@ -127,7 +131,7 @@ create_code_slice() {
|
|||||||
trap "echo 'Running exit trap code' ; df -i ${MNT} ; nano_umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT
|
trap "echo 'Running exit trap code' ; df -i ${MNT} ; nano_umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT
|
||||||
|
|
||||||
gpart create -s bsd "${MD}"
|
gpart create -s bsd "${MD}"
|
||||||
gpart add -t freebsd-ufs -b 16 "${MD}"
|
gpart add -t freebsd-ufs -b "${METADATA_SECTS}" "${MD}"
|
||||||
if [ -f ${NANO_WORLDDIR}/boot/boot ]; then
|
if [ -f ${NANO_WORLDDIR}/boot/boot ]; then
|
||||||
echo "Making bootable partition"
|
echo "Making bootable partition"
|
||||||
gpart bootcode -b ${NANO_WORLDDIR}/boot/boot ${MD}
|
gpart bootcode -b ${NANO_WORLDDIR}/boot/boot ${MD}
|
||||||
@@ -172,8 +176,8 @@ _create_code_slice() {
|
|||||||
echo "Partition will not be bootable"
|
echo "Partition will not be bootable"
|
||||||
fi
|
fi
|
||||||
nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
|
nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
|
||||||
"${NANO_METALOG}" "${CODE_SIZE}" "${NANO_OBJ}/_.disk.part" \
|
"${NANO_METALOG}" "$(( CODE_SIZE - METADATA_SECTS ))" \
|
||||||
"${NANO_WORLDDIR}"
|
"${NANO_OBJ}/_.disk.part" "${NANO_WORLDDIR}"
|
||||||
mkimg -s bsd \
|
mkimg -s bsd \
|
||||||
${bootcode} \
|
${bootcode} \
|
||||||
-p freebsd-ufs:="${NANO_OBJ}/_.disk.part" \
|
-p freebsd-ufs:="${NANO_OBJ}/_.disk.part" \
|
||||||
@@ -308,8 +312,8 @@ _create_diskimage() {
|
|||||||
echo "Duplicating to second image..."
|
echo "Duplicating to second image..."
|
||||||
tgt_switch_root_fstab "${NANO_SLICE_ROOT}" "${NANO_SLICE_ALTROOT}"
|
tgt_switch_root_fstab "${NANO_SLICE_ROOT}" "${NANO_SLICE_ALTROOT}"
|
||||||
nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
|
nano_makefs "-DxZ ${NANO_MAKEFS} -o minfree=0,optimization=space" \
|
||||||
"${NANO_METALOG}" "${CODE_SIZE}" "${NANO_OBJ}/_.altroot.part" \
|
"${NANO_METALOG}" "$(( CODE_SIZE - METADATA_SECTS ))" \
|
||||||
"${NANO_WORLDDIR}"
|
"${NANO_OBJ}/_.altroot.part" "${NANO_WORLDDIR}"
|
||||||
tgt_switch_root_fstab "${NANO_SLICE_ALTROOT}" "${NANO_SLICE_ROOT}"
|
tgt_switch_root_fstab "${NANO_SLICE_ALTROOT}" "${NANO_SLICE_ROOT}"
|
||||||
if [ -f "${NANO_WORLDDIR}/boot/boot" ]; then
|
if [ -f "${NANO_WORLDDIR}/boot/boot" ]; then
|
||||||
bootcode="-b ${NANO_WORLDDIR}/boot/boot"
|
bootcode="-b ${NANO_WORLDDIR}/boot/boot"
|
||||||
|
|||||||
Reference in New Issue
Block a user