>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 
[email protected]:/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=<size>
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:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to