From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 8 20:30:01 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3404919A for ; Thu, 8 Nov 2012 20:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 095DC8FC14 for ; Thu, 8 Nov 2012 20:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id qA8KU0I1067181 for ; Thu, 8 Nov 2012 20:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qA8KU0uE067180; Thu, 8 Nov 2012 20:30:00 GMT (envelope-from gnats) Resent-Date: Thu, 8 Nov 2012 20:30:00 GMT Resent-Message-Id: <201211082030.qA8KU0uE067180@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, Nick Hibma Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F15C18B for ; Thu, 8 Nov 2012 20:29:29 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id D1FCB8FC14 for ; Thu, 8 Nov 2012 20:29:28 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qA8KTSF6063500 for ; Thu, 8 Nov 2012 20:29:28 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id qA8KTSmg063499; Thu, 8 Nov 2012 20:29:28 GMT (envelope-from nobody) Message-Id: <201211082029.qA8KTSmg063499@red.freebsd.org> Date: Thu, 8 Nov 2012 20:29:28 GMT From: Nick Hibma To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/173482: [Patch] NanoBSD images should be created sparsely. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Nov 2012 20:30:01 -0000 >Number: 173482 >Category: misc >Synopsis: [Patch] NanoBSD images should be created sparsely. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Nov 08 20:30:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Nick Hibma >Release: FreeBSD 8.3-RELEASE i386 >Organization: AnyWi Technologies >Environment: System: FreeBSD bitske2.localdomain 8.3-RELEASE FreeBSD 8.3-RELEASE #0 r242660: Tue Nov 6 16:23:23 CET 2012 root@bitske2.localdomain:/usr/obj/usr/src/sys/GENERIC i386 >Description: When an image is copied out into _.disk.image this could be done sparsely. I use a Virtual machine to build the images, and writing them sparsely saves time and space. This makes a huge difference when not initialising the second partition (NANO_INIT_IMG2=0) Note: The backing files are already created sparsely (using 'seek= count=0' arguments to dd). The diff below contains also a comment on how to speed up installing packages (using a null mount instead of copying the packages across). We install several MBs of packages and this speeds things up dramatically. A similar piece of code works beautifully in our package install (which cherry-picks the packages that need to be installed instead of installing the packages wholesale). >How-To-Repeat: >Fix: --- AnyWi/freebsd/nanobsd/nanobsd.sh 2012-11-08 19:48:40.000000000 +0100 +++ /usr/src/tools/tools/nanobsd/nanobsd.sh 2012-11-06 15:24:52.000000000 +0100 @@ -540,7 +540,7 @@ if [ $NANO_IMAGES -gt 1 -a $NANO_INIT_IMG2 -gt 0 ] ; then # Duplicate to second image (if present) echo "Duplicating to second image..." - dd conv=sparse if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k + dd if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k mount /dev/${MD}s2a ${MNT} for f in ${MNT}/etc/fstab ${MNT}/conf/base/etc/fstab do @@ -569,7 +569,7 @@ if ${do_copyout_partition} ; then echo "Writing out _.disk.image..." - dd conv=sparse if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k + dd if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k fi mdconfig -d -u $MD @@ -683,16 +683,6 @@ # Install packages from ${NANO_PACKAGE_DIR} cust_pkg () ( - # XXX This should be replaced by a nullfs mount, like so - # mkdir -p ${NANO_WORLDDIR}/Pkg - # trap "umount ${NANO_PACKAGE_DIR}Pkg" 1 2 3 15 EXIT - # mount -t nullfs ${NANO_PACKAGE_DIR}Pkg ${NANO_WORLDDIR}/Pkg - # and replace the rm -rf below with the following: - # umount $NANO_WORLDDIR$PKG_PATH - # rmdir $NANO_WORLDDIR$PKG_PATH - # trap - 1 2 3 15 EXIT - # Missing is the handling of selecting the packages to install. The - # loop below needs to be rewritten. # If the package directory doesn't exist, we're done. if [ ! -d ${NANO_PACKAGE_DIR} ]; then >Release-Note: >Audit-Trail: >Unformatted: