NanoBSD: Create image sparsely

Nick Hibma nick at van-laarhoven.org
Thu Nov 29 07:52:08 UTC 2012


In the past I have submitted patches to create images sparsely. There is however one patch missing still which, with the addition of NANO_INIT_IMG2, has become much more useful:

--- 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 if=/dev/${MD}s1 of=/dev/${MD}s2 bs=64k
+               dd conv=sparse 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 if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k
+          dd conv=sparse if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k
   fi
     mdconfig -d -u $MD
 
It copies out the image sparsely (conv=sparse). The big advantage comes when creating many images (I have between 10 and 20 images simultaneously on my disk).

Any objections to this? (*)

Nick Hibma
nick at van-laarhoven.org


More information about the freebsd-embedded mailing list