Make the slice names for root configurable. For embedded platforms, we
need s1 to be a FAT partition, s2 to be the config partition and s3 and s4 to be the ping-pong upgrade partitions. NANO_SLICE_ROOT defaults to s1 NANO_SLICE_ALTROOT defaults to s2 NANO_SLICE_CFG defaults to s3 NANO_SLICE_DATA defaults to s4 All can be overridden in the config file. Some basic sanity checking is in place, but is no substitute for being careful.
This commit is contained in:
parent
35cfb2619f
commit
7b77d3ea7f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290704
@ -152,6 +152,11 @@ PPLEVEL=3
|
|||||||
# /cfg partition will be ${NANO_LABEL}s3
|
# /cfg partition will be ${NANO_LABEL}s3
|
||||||
# /data partition will be ${NANO_LABEL}s4
|
# /data partition will be ${NANO_LABEL}s4
|
||||||
NANO_LABEL=""
|
NANO_LABEL=""
|
||||||
|
NANO_SLICE_ROOT=s1
|
||||||
|
NANO_SLICE_ALTROOT=s2
|
||||||
|
NANO_SLICE_CFG=s3
|
||||||
|
NANO_SLICE_DATA=s4
|
||||||
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Architecture to build. Corresponds to TARGET_ARCH in a buildworld.
|
# Architecture to build. Corresponds to TARGET_ARCH in a buildworld.
|
||||||
@ -410,7 +415,6 @@ setup_nanobsd ( ) (
|
|||||||
# link /$d under /conf
|
# link /$d under /conf
|
||||||
# we use hard links so we have them both places.
|
# we use hard links so we have them both places.
|
||||||
# the files in /$d will be hidden by the mount.
|
# the files in /$d will be hidden by the mount.
|
||||||
# XXX: configure /$d ramdisk size
|
|
||||||
mkdir -p conf/base/$d conf/default/$d
|
mkdir -p conf/base/$d conf/default/$d
|
||||||
find $d -print | cpio -dumpl conf/base/
|
find $d -print | cpio -dumpl conf/base/
|
||||||
done
|
done
|
||||||
@ -419,7 +423,7 @@ setup_nanobsd ( ) (
|
|||||||
echo "$NANO_RAM_TMPVARSIZE" > conf/base/var/md_size
|
echo "$NANO_RAM_TMPVARSIZE" > conf/base/var/md_size
|
||||||
|
|
||||||
# pick up config files from the special partition
|
# pick up config files from the special partition
|
||||||
echo "mount -o ro /dev/${NANO_DRIVE}s3" > conf/default/etc/remount
|
echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount
|
||||||
|
|
||||||
# Put /tmp on the /var ramdisk (could be symlink already)
|
# Put /tmp on the /var ramdisk (could be symlink already)
|
||||||
nano_rm -rf tmp
|
nano_rm -rf tmp
|
||||||
@ -443,8 +447,8 @@ setup_nanobsd_etc ( ) (
|
|||||||
# save config file for scripts
|
# save config file for scripts
|
||||||
echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
|
echo "NANO_DRIVE=${NANO_DRIVE}" > etc/nanobsd.conf
|
||||||
|
|
||||||
echo "/dev/${NANO_DRIVE}s1a / ufs ro 1 1" > etc/fstab
|
echo "/dev/${NANO_DRIVE}${NANO_SLICE_ROOT}a / ufs ro 1 1" > etc/fstab
|
||||||
echo "/dev/${NANO_DRIVE}s3 /cfg ufs rw,noauto 2 2" >> etc/fstab
|
echo "/dev/${NANO_DRIVE}${NANO_SLICE_CFG} /cfg ufs rw,noauto 2 2" >> etc/fstab
|
||||||
mkdir -p cfg
|
mkdir -p cfg
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -598,15 +602,15 @@ create_diskimage ( ) (
|
|||||||
boot0cfg -B -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOT0CFG} ${MD}
|
boot0cfg -B -b ${NANO_WORLDDIR}/${NANO_BOOTLOADER} ${NANO_BOOT0CFG} ${MD}
|
||||||
fi
|
fi
|
||||||
if [ -f ${NANO_WORLDDIR}/boot/boot ]; then
|
if [ -f ${NANO_WORLDDIR}/boot/boot ]; then
|
||||||
bsdlabel -w -B -b ${NANO_WORLDDIR}/boot/boot ${MD}s1
|
bsdlabel -w -B -b ${NANO_WORLDDIR}/boot/boot ${MD}${NANO_SLICE_ROOT}
|
||||||
else
|
else
|
||||||
bsdlabel -w ${MD}s1
|
bsdlabel -w ${MD}${NANO_SLICE_ROOT}
|
||||||
fi
|
fi
|
||||||
bsdlabel ${MD}s1
|
bsdlabel ${MD}${NANO_SLICE_ROOT}
|
||||||
|
|
||||||
# Create first image
|
# Create first image
|
||||||
populate_slice /dev/${MD}s1a ${NANO_WORLDDIR} ${MNT} "s1a"
|
populate_slice /dev/${MD}${NANO_SLICE_ROOT}a ${NANO_WORLDDIR} ${MNT} "${NANO_SLICE_ROOT}a"
|
||||||
mount /dev/${MD}s1a ${MNT}
|
mount /dev/${MD}${NANO_SLICE_ROOT}a ${MNT}
|
||||||
echo "Generating mtree..."
|
echo "Generating mtree..."
|
||||||
( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree
|
( cd ${MNT} && mtree -c ) > ${NANO_OBJ}/_.mtree
|
||||||
( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du
|
( cd ${MNT} && du -k ) > ${NANO_OBJ}/_.du
|
||||||
@ -615,26 +619,31 @@ create_diskimage ( ) (
|
|||||||
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
|
if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then
|
||||||
# Duplicate to second image (if present)
|
# Duplicate to second image (if present)
|
||||||
echo "Duplicating to second image..."
|
echo "Duplicating to second image..."
|
||||||
dd conv=sparse if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k
|
dd conv=sparse if=/dev/${MD}${NANO_SLICE_ROOT} of=/dev/${MD}${NANO_SLICE_ALTROOT} bs=64k
|
||||||
mount /dev/${MD}s2a ${MNT}
|
mount /dev/${MD}${NANO_SLICE_ALTROOT}a ${MNT}
|
||||||
for f in ${MNT}/etc/fstab ${MNT}/conf/base/etc/fstab
|
for f in ${MNT}/etc/fstab ${MNT}/conf/base/etc/fstab
|
||||||
do
|
do
|
||||||
sed -i "" "s=${NANO_DRIVE}s1=${NANO_DRIVE}s2=g" $f
|
sed -i "" "s=${NANO_DRIVE}${NANO_SLICE_ROOT}=${NANO_DRIVE}${NANO_SLICE_ALTROOT}=g" $f
|
||||||
done
|
done
|
||||||
nano_umount ${MNT}
|
nano_umount ${MNT}
|
||||||
# Override the label from the first partition so we
|
# Override the label from the first partition so we
|
||||||
# don't confuse glabel with duplicates.
|
# don't confuse glabel with duplicates.
|
||||||
if [ ! -z ${NANO_LABEL} ]; then
|
if [ ! -z ${NANO_LABEL} ]; then
|
||||||
tunefs -L ${NANO_LABEL}"s2a" /dev/${MD}s2a
|
tunefs -L ${NANO_LABEL}"${NANO_SLICE_ALTROOT}a" /dev/${MD}${NANO_SLICE_ALTROOT}a
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create Config slice
|
# Create Config slice
|
||||||
populate_cfg_slice /dev/${MD}s3 "${NANO_CFGDIR}" ${MNT} "s3"
|
populate_cfg_slice /dev/${MD}${NANO_SLICE_CFG} "${NANO_CFGDIR}" ${MNT} "${NANO_SLICE_CFG}"
|
||||||
|
|
||||||
# Create Data slice, if any.
|
# Create Data slice, if any.
|
||||||
if [ $NANO_DATASIZE -ne 0 ] ; then
|
if [ ! -z $NANO_SLICE_DATA -a $NANO_SLICE_CFG = $NANO_SLICE_DATA -a \
|
||||||
populate_data_slice /dev/${MD}s4 "${NANO_DATADIR}" ${MNT} "s4"
|
$NANO_DATASIZE -ne 0 ]; then
|
||||||
|
pprint 2 "NANO_SLICE_DATA is the same as NANO_SLICE_CFG, fix."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [ $NANO_DATASIZE -ne 0 -a ! -z $NANO_SLICE_DATA ] ; then
|
||||||
|
populate_data_slice /dev/${MD}${NANO_SLICE_DATA} "${NANO_DATADIR}" ${MNT} "${NANO_SLICE_DATA}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${NANO_MD_BACKING}" = "swap" ] ; then
|
if [ "${NANO_MD_BACKING}" = "swap" ] ; then
|
||||||
@ -652,7 +661,7 @@ create_diskimage ( ) (
|
|||||||
|
|
||||||
if ${do_copyout_partition} ; then
|
if ${do_copyout_partition} ; then
|
||||||
echo "Writing out _.disk.image..."
|
echo "Writing out _.disk.image..."
|
||||||
dd conv=sparse if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k
|
dd conv=sparse if=/dev/${MD}${NANO_SLICE_ROOT} of=${NANO_DISKIMGDIR}/_.disk.image bs=64k
|
||||||
fi
|
fi
|
||||||
mdconfig -d -u $MD
|
mdconfig -d -u $MD
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user