From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 24 18:40:11 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 365E0106567A for ; Sun, 24 Oct 2010 18:40:11 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 167648FC0A for ; Sun, 24 Oct 2010 18:40:11 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o9OIeAjl030350 for ; Sun, 24 Oct 2010 18:40:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9OIeALR030346; Sun, 24 Oct 2010 18:40:10 GMT (envelope-from gnats) Resent-Date: Sun, 24 Oct 2010 18:40:10 GMT Resent-Message-Id: <201010241840.o9OIeALR030346@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Lev Serebryakov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B59721065679 for ; Sun, 24 Oct 2010 18:37:46 +0000 (UTC) (envelope-from lev@ftp.translate.ru) Received: from ftp.translate.ru (ftp.translate.ru [80.249.188.42]) by mx1.freebsd.org (Postfix) with ESMTP id 49C0C8FC12 for ; Sun, 24 Oct 2010 18:37:46 +0000 (UTC) Received: by ftp.translate.ru (Postfix, from userid 1000) id 6619F13DF46; Sun, 24 Oct 2010 22:37:45 +0400 (MSD) Message-Id: <20101024183745.6619F13DF46@ftp.translate.ru> Date: Sun, 24 Oct 2010 22:37:45 +0400 (MSD) From: Lev Serebryakov To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: misc/151698: [nanobsd] [patch] Add two new options to nanobsd.sh to make rebuilds faster X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Lev Serebryakov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2010 18:40:11 -0000 >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 root@vmware-8-32.home.serebryakov.spb.ru:/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: