From 8a3e74117a1d5b6ee47a3e0d7f02a4873a2fdb26 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 29 Jan 2017 14:49:10 +0100 Subject: [PATCH 150/325] release/rc.local: Let the memstick create a script to self-reproduce Only works if there's enough free space at the end of the device the image is located on. Before trying to reproduce in a virtualized environment like bhyve increase the memstick size with something like: truncate -s +20G [...]/ElectroBSD-r314503-7314f38a400e.img Obtained from: ElectroBSD --- release/rc.local | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/release/rc.local b/release/rc.local index 7acf5070ef5e..776ab73e9719 100755 --- a/release/rc.local +++ b/release/rc.local @@ -10,6 +10,35 @@ MACHINE=`uname -m` +# create a script that can be used to reproduce the image with itself +# (provided there is enough space at the end to create another partition) +cat << 'EOF' > /tmp/reproduce-from-image.sh +set -x -e +# Fingers crossed that the first disk is the boot disk ... +DISK=$(geom disk status -s | head -n 1 | cut -f 1 -w) +JAILROOT="$(mktemp -d /tmp/ElectroBSD-jail-XXXXXX)" +SWAP_PARTITION_INDEX=3 +BUILD_PARTITION_INDEX=4 + +gpart recover "${DISK}" +gpart add -t freebsd-swap -s 1500M "${DISK}" +swapon "/dev/${DISK}p${SWAP_PARTITION_INDEX}" +dumpon "/dev/${DISK}p${SWAP_PARTITION_INDEX}" +gpart add -t freebsd-ufs "${DISK}" +# gpart partition changes made in bhyve are currently +# lost. The cause hasn't been diagnosed yet. +# Explicitly include the partition layout in the +# presumably logged output so it can be restored +# afterwards. +gpart show "${DISK}" # More convenient format for humans +gpart backup "${DISK}" # Same data in format understood by "gpart restore" +newfs "/dev/${DISK}p${BUILD_PARTITION_INDEX}" +mount -o async,noatime "/dev/${DISK}p${BUILD_PARTITION_INDEX}" "${JAILROOT}" +tar xf /usr/electrobsd-dist/base.txz -C "${JAILROOT}" +tar xf /usr/electrobsd-dist/src.txz -C "${JAILROOT}" +time jail -c path="${JAILROOT}" mount.devfs host.hostname=ElectroBSD command=sh /usr/src/reproduce.sh +EOF + # resolv.conf from DHCP ends up in here, so make sure the directory exists mkdir /tmp/bsdinstall_etc -- 2.32.0