Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167386399
D58982.id184606.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D58982.id184606.diff
View Options
diff --git a/tools/tools/nanobsd/customizations.sh b/tools/tools/nanobsd/customizations.sh
--- a/tools/tools/nanobsd/customizations.sh
+++ b/tools/tools/nanobsd/customizations.sh
@@ -132,9 +132,14 @@
if $do_clean; then
tgt_pkg install -F $NANO_PACKAGE_LIST
fi
+ mount -t nullfs -o noatime -o ro "$(nano_pkg_cachedir)" "${NANO_WORLDDIR}/var/cache/pkg"
+ trap "nano_umount ${NANO_WORLDDIR}/var/cache/pkg" 1 2 15 EXIT
fi
- tgt_pkg install $NANO_PACKAGE_LIST
+ cp /etc/resolv.conf "${NANO_WORLDDIR}/etc/resolv.conf"
+ tgt_pkg_chroot install $NANO_PACKAGE_LIST
+ rm -f "${NANO_WORLDDIR}/etc/resolv.conf"
+ rm -rf "${NANO_WORLDDIR}/var/db/pkg/repos/"*
if [ -d "$NANO_PACKAGE_DIR" ]; then
trap - 1 2 15 EXIT
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -154,11 +154,14 @@
NANO_SWAP_SIZE=0
# Swap partition encryption
-NANO_SWAP_ENCRYPTION=""
+NANO_SWAP_ENCRYPTION=
# EFI System Partition size in bytes
NANO_EFI_BOOTPART_SIZE="260Mi"
+# CIDATA Partition size in bytes (nuageinit)
+NANO_CIDATA_SIZE=0
+
# Progress Print level
PPLEVEL=3
@@ -571,8 +574,6 @@
}
# Run pkg(8) with the configured ABI, repo, and cache settings
-=======
->>>>>>> 023e4881b1a (nanobsd: Disable pkg repositories on target image)
pkg_cmd() {
pkg --repo-conf-dir "$(nano_pkg_repos_dir)" \
-o ABI="$NANO_ABI" \
@@ -1553,8 +1554,7 @@
#
# Thin wrapper around populate_part for creating
# the configuration partition image file
-# Input: $1 = image path, $2 = source dir, $3 = slice number,
-# $4 = size in sectors, $5 = metalog
+# Input: $1 = image path, $2 = source dir, $3 = label, $4 = size, $5 = metalog
#
populate_cfg_part() {
populate_part "cfg" "$1" "$2" "$3" "$4" "$5"
@@ -1811,6 +1811,7 @@
NANO_RAM_ETCSIZE=$(strtobytes "${NANO_RAM_ETCSIZE:-0}")
NANO_RAM_TMPVARSIZE=$(strtobytes "${NANO_RAM_TMPVARSIZE:-0}")
NANO_SWAP_SIZE=$(strtobytes "${NANO_SWAP_SIZE:-0}")
+ NANO_CIDATA_SIZE=$(strtobytes "${NANO_CIDATA_SIZE:-0}")
NANO_EFI_BOOTPART_SIZE=$(strtobytes "${NANO_EFI_BOOTPART_SIZE:-0}")
fi
@@ -1829,6 +1830,7 @@
export_var MAKEOBJDIRPREFIX
export_var NANO_ARCH
export_var NANO_BOOTLOADER
+ export_var NANO_CIDATA_SIZE
export_var NANO_CODESIZE
export_var NANO_CONFSIZE
export_var NANO_CUSTOMIZE
diff --git a/tools/tools/nanobsd/gpt.sh b/tools/tools/nanobsd/gpt.sh
--- a/tools/tools/nanobsd/gpt.sh
+++ b/tools/tools/nanobsd/gpt.sh
@@ -74,6 +74,9 @@
tgt_touch etc/nanobsd.conf
printf_fstab "# Device" Mountpoint FStype Options Dump "Pass#"
+ if [ "$NANO_CIDATA_SIZE" -gt 0 ]; then
+ printf_fstab "/dev/msdosfs/CIDATA" /boot/cidata msdosfs rw,noauto 2 2
+ fi
if is_boot_type UEFI; then
printf_fstab "/dev/gpt/efiboot0" /boot/efi msdosfs rw,noauto 2 2
fi
@@ -188,6 +191,41 @@
rm -rf "$espdir"
}
+# Create an MS Basic Data Partition for nuageinit (cidata)
+make_cidata_partition() {
+ local cidatadir cidata_sects fat_type
+
+ # Since sectors_per_cluster=1, assume 1 cluster = 1 sector
+ MINCLS16=4085 # minimum FAT16 clusters (0xff5U)
+ MINCLS32=65525 # minimum FAT32 clusters (0xfff5U)
+ cidata_sects=$(awk -v label="cidata" '$5 == label {print $4}' "${NANO_LOG}/_.partitioning")
+ if [ "$cidata_sects" -ge "$MINCLS32" ]; then
+ fat_type=32
+ elif [ "$cidata_sects" -ge "$MINCLS16" ]; then
+ fat_type=16
+ else
+ fat_type=12
+ fi
+
+ cidatadir="${NANO_OBJ}/_.cidata"
+ rm -rf "$cidatadir"
+ mkdir -p "$cidatadir"
+ # XXX: Where should we mount /boot/msdos?
+ # XXX: This mkdir -p operation has to be performed earlier than create_code_partition
+ mkdir -p "${NANO_WORLDDIR}/boot/cidata"
+
+ makefs -t msdos \
+ -o fat_type="$fat_type" \
+ -o sectors_per_cluster=1 \
+ -o volume_label="cidata" \
+ -o OEM_string="" \
+ -s "${cidata_sects}b" \
+ -T "$NANO_TIMESTAMP" \
+ "${NANO_OBJ}/_.cidata.image" "$cidatadir"
+
+ rm -rf "$cidatadir"
+}
+
#
# Calculate partition sizes aligned at NANO_ALIGN boundaries.
# All sizes are in bytes.
@@ -208,19 +246,26 @@
boot_sects=$(( boot_size / NANO_SECTOR_SIZE ))
fi
is_boot_type UEFI && esp_sects=$(( NANO_EFI_BOOTPART_SIZE / NANO_SECTOR_SIZE ))
+ [ -n "$NANO_CIDATA_SIZE" ] && cidata_sects=$(( NANO_CIDATA_SIZE / NANO_SECTOR_SIZE ))
echo "$NANO_MEDIASIZE" "$NANO_IMAGES" "$NANO_SECTOR_SIZE" \
"$NANO_CODESIZE" "$NANO_CONFSIZE" "$NANO_DATASIZE" "$boot_type" \
"$boot_sects" "$esp_sects" "$NANO_SWAP_SIZE" "$NANO_ROOT" \
"$NANO_ALTROOT" "$NANO_PARTITION_CFG" "$NANO_PARTITION_DATA" \
- "$align" |
- awk '
+ "$align" "$cidata_sects" | awk '
function roundup(sects) {
return int((sects + align - 1) / align) * align
}
function print_line(type, sects, label, windex, wtype, wblocks) {
windex = 3
- wtype = ($7 == 1 || swap_sects > 0) ? length("freebsd-swap") : length("freebsd-ufs")
+ if (cidata_sects > 0) {
+ wtype = "ms-basic-data"
+ } else if (swap_sects > 0) {
+ wtype = "freebsd-swap"
+ } else {
+ wtype = "freebsd-ufs"
+ }
+ wtype = length(wtype)
wblocks = length(media_sects)
printf "%-*s %*s %*s %*s %s\n",
@@ -251,6 +296,9 @@
# Boot size in sectors (already rounded up)
boot_sects = ($8 > 0) ? $8 : 0
+ # CIDATA size in sectors (rounded up)
+ cidata_sects = ($16 > 0) ? roundup($16) : 0
+
# ESP size in sectors (rounded up)
esp_sects = ($9 > 0) ? roundup($9) : 0
@@ -284,12 +332,16 @@
avail_sects -= (align - sstart)
sstart = align
+ # CIDATA partition (if any)
+ if (cidata_sects > 0) {
+ print_line("ms-basic-data", cidata_sects, "cidata")
+ }
+
# ESP partition (if any)
if (esp_sects > 0) {
print_line("efi", esp_sects, "efiboot0")
}
- # Swap partition (if any)
if (swap_sects > 0) {
print_line("freebsd-swap", swap_sects, "swap0")
}
@@ -300,15 +352,17 @@
# (rounded down)
total_code_sects = avail_sects - cfg_sects - \
((data_sects > 0) ? data_sects : 0)
- code_sects = int(total_code_sects / $2)
+ total_code_sects = int(total_code_sects / align) * align
+ code_sects = int((total_code_sects / $2) / align) * align
} else {
+ # (rounded up)
code_sects = roundup(code_sects)
}
- # Primary code partition
+ # First code partition
print_line("freebsd-ufs", code_sects, $11)
- # Secondary code partition (if any)
+ # Second code partition (if any)
if ($2 > 1) {
print_line("freebsd-ufs", code_sects, $12)
}
@@ -317,12 +371,10 @@
print_line("freebsd-ufs", cfg_sects, $13)
# Data partition (if any)
- if (data_sects < 0) {
- # (rounded down)
- data_sects = avail_sects
- }
if (data_sects > 0) {
print_line("freebsd-ufs", data_sects, $14)
+ } else if (data_sects < 0 && avail_sects > 0) {
+ print_line("freebsd-ufs", avail_sects, $14)
}
# Overcommit check
@@ -331,8 +383,7 @@
(avail_sects * -1), "sectors" > "/dev/stderr"
exit 2
}
- }
- ' > "${NANO_LOG}/_.partitioning"
+ }' > "${NANO_LOG}/_.partitioning"
}
# Create the code partition image
@@ -364,7 +415,7 @@
(
local IMG code_sects code_size cfg_sects cfg_size data_sects data_size
- local bootcode cfg data efiboot0 gptboot0 swap0
+ local bootcode cfg cidata data efiboot0 gptboot0 swap0
local code1 "${NANO_ROOT}" code2 "${NANO_ALTROOT}" # XXX: NANO_ALTROOT
IMG=${NANO_DISKIMGDIR}/${NANO_IMGNAME}
@@ -380,7 +431,7 @@
bootcode="-b ${NANO_WORLDDIR}/boot/pmbr"
fi
- for image in gptboot0 efiboot0 swap0 \
+ for image in gptboot0 cidata efiboot0 swap0 \
${NANO_ROOT} ${NANO_ALTROOT} cfg data; do
match=$(awk -v dir="$NANO_OBJ" -v img="$image" -v ssize="$NANO_SECTOR_SIZE" \
'$5 == img {
@@ -406,17 +457,17 @@
code1=$(echo "$code1" | sed "s|${NANO_OBJ}/_.${NANO_ROOT}.image|${NANO_DISKIMGDIR}/${NANO_IMG1NAME}|")
# Create boot partition (if any)
- if is_boot_type BIOS; then
- make_boot_partition "gptboot0"
- fi
+ is_boot_type BIOS && make_boot_partition
+
+ # Create CIDATA partition (if any)
+ [ "$NANO_CIDATA_SIZE" -gt 0 ] && make_cidata_partition
# Create ESP partition (if any)
- if is_boot_type UEFI; then
- make_esp_partition "efiboot0"
- fi
+ is_boot_type UEFI && make_esp_partition
# Swap partition must be greater than 100 MiB
- if [ "$NANO_SWAP_SIZE" -gt 0 ] && [ "$NANO_SWAP_SIZE" -lt 104857600 ]; then
+ if [ "$NANO_SWAP_SIZE" -gt 0 ] &&
+ [ "$NANO_SWAP_SIZE" -lt "$(strtobytes 100MiB)" ]; then
err "Swap size (${NANO_SWAP_SIZE}) too small (must be > 100 MiB)."
fi
@@ -452,6 +503,7 @@
--capacity ${NANO_MEDIASIZE} \
${bootcode} \
${gptboot0} \
+ ${cidata} \
${efiboot0} \
${swap0} \
${code1} \
@@ -462,6 +514,7 @@
# Cleanup
rm -f "${NANO_OBJ}/_.gptboot0.image" \
+ "${NANO_OBJ}/_.cidata.image" \
"${NANO_OBJ}/_.efiboot0.image" \
"${NANO_OBJ}/_.${NANO_ALTROOT}.image" \
"${NANO_OBJ}/_.cfg.image" \
diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh
--- a/tools/tools/nanobsd/legacy.sh
+++ b/tools/tools/nanobsd/legacy.sh
@@ -247,6 +247,7 @@
# Note: we use the is_defined hack to catch most uses of function redefinition
# in config files. Older versions of FreeBSD defined these before configs were
# included, but now we define it after to allow different NANO_PLAN...
+
#
# Calculate MBR partition layout (start offset, size, index)
# from media/image/code/conf/data sizes
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh
--- a/tools/tools/nanobsd/nanobsd.sh
+++ b/tools/tools/nanobsd/nanobsd.sh
@@ -34,6 +34,8 @@
. "${topdir}/customizations.sh"
. "${topdir}/_xxx_includes.subr" # XXX ideally, this file should not exist
+# XXX: Remove this function? It is used in a later revision/PR, so
+# verify thoroughly before removing.
is_defined() {
case $(type $1 2>/dev/null) in
*function) return 0 ;;
@@ -48,7 +50,6 @@
}
default() {
- # Pull in default stuff on demand
. "${topdir}/gpt.sh"
NANO_PLAN="${NANO_PLAN:-default}"
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 22, 12:08 PM (17 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37070317
Default Alt Text
D58982.id184606.diff (9 KB)
Attached To
Mode
D58982: nanobsd: Add an optional CIDATA partition
Attached
Detach File
Event Timeline
Log In to Comment