>Number: 151698
>Category: misc
>Synopsis: [nanobsd] [patch] Add two new options to nanobsd.sh to make
>rebuilds faster
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Oct 24 18:40:10 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Lev Serebryakov
>Release: FreeBSD 8.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD vmware-8-32.home.serebryakov.spb.ru 8.1-STABLE FreeBSD
8.1-STABLE #1: Wed Oct 20 18:55:10 MSD 2010
[email protected]:/usr/obj/usr/src/sys/GENERIC i386
>Description:
This patch adds two new options to nanobsd.sh:
-f ([f]ast) options supress of extraction of CODE slice (s1) from final
image. If you need full image to prepare new device, you don't need separate
file with CODE slice, and this otions saves lots of time.
-z ([z]ap) option works only if NANO_MD_BACKING=file and supresses creation
of image file from "/dev/zero". It zeroes out two first cylinders of EXISTENT
image file, left from previous runs. If image file is absent or has wrong size,
process stops.
These two options, when used together, make experiments with creating NanoBSD
images MUCH faster even on modern hardware.
>How-To-Repeat:
>Fix:
--- nanobsd.sh.orig 2010-10-24 22:20:07.000000000 +0400
+++ nanobsd.sh.faster 2010-10-24 22:22:28.000000000 +0400
@@ -466,9 +466,20 @@
MD=`mdconfig -a -t swap -s ${NANO_MEDIASIZE} -x ${NANO_SECTS} \
-y ${NANO_HEADS}`
else
- echo "Creating md backing file..."
- dd if=/dev/zero of=${IMG} bs=${NANO_SECTS}b \
- count=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}`
+ if $do_create_md_file || ! [ -f ${IMG} ] ; then
+ echo "Creating md backing file..."
+ dd if=/dev/zero of=${IMG} bs=${NANO_SECTS}b \
+ count=`expr ${NANO_MEDIASIZE} / ${NANO_SECTS}`
+ else
+ echo "Check & zap md backing file..."
+ MD_SIZE=`stat -f '%z' ${IMG}`
+ MD_SIZE=$(( ${MDSIZE} / 512 ))
+ if [ "${MD_SIZE}" != "${NANO_MEDIASIZE}" ] ; then
+ echo "Invalid ${IMG} size (found ${MD_SIZE}
sectors, need ${NANO_MEDIASIZE})"
+ exit 1
+ fi
+ dd if=/dev/zero of=${IMG} bs=1024 count=`expr
${NANO_SECTS} '*' ${NANO_HEADS}` conv=notrunc
+ fi
MD=`mdconfig -a -t vnode -f ${IMG} -x ${NANO_SECTS} \
-y ${NANO_HEADS}`
fi
@@ -521,8 +532,10 @@
dd if=/dev/${MD} of=${IMG} bs=64k
fi
- echo "Writing out _.disk.image..."
- dd if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k
+ if do_copyout_partition ; then
+ echo "Writing out _.disk.image..."
+ dd if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k
+ fi
mdconfig -d -u $MD
trap - 1 2 15 EXIT
@@ -712,14 +725,16 @@
usage () {
(
- echo "Usage: $0 [-biknqvw] [-c config_file]"
+ echo "Usage: $0 [-bfiknqvwz] [-c config_file]"
echo " -b suppress builds (both kernel and world)"
+ echo " -f suppress code slice extraction"
echo " -i suppress disk image build"
echo " -k suppress buildkernel"
echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc"
echo " -q make output more quiet"
echo " -v make output more verbose"
echo " -w suppress buildworld"
+ echo " -z use existing disk image instead creating new one"
echo " -c specify config file"
) 1>&2
exit 2
@@ -732,9 +747,11 @@
do_kernel=true
do_world=true
do_image=true
+do_create_md_file=true
+do_copyout_partition=true
set +e
-args=`getopt bc:hiknqvw $*`
+args=`getopt bc:fhiknqvwz $*`
if [ $? -ne 0 ] ; then
usage
exit 2
@@ -760,6 +777,10 @@
shift
shift
;;
+ -f)
+ do_copyout_partition=false
+ shift
+ ;;
-h)
usage
;;
@@ -783,6 +804,10 @@
do_world=false
shift
;;
+ -z)
+ do_create_md_file=true
+ shift
+ ;;
--)
shift
break
>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"