Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] tools/do_gpt.sh calls makefs in an inefficient manner #44

Open
ngie-eign opened this issue Oct 10, 2014 · 1 comment
Open

[PATCH] tools/do_gpt.sh calls makefs in an inefficient manner #44

ngie-eign opened this issue Oct 10, 2014 · 1 comment

Comments

@ngie-eign
Copy link

According to one of our internal developers, calling makefs as-is in tools/do_gpt.sh is very slow. I've provided the patch below.

I would go one step further and say that the filesystem disk should be created in a sparse manner, not as a densely populated disk image.

Also, the block size is small (1kB). It could and should be larger (1MB at least).

A lot of this should be fixed/improved with the mkimg utility in 11+, but that's a different utility for a different day...

commit e10947989b275767e1e2e5a4e0bd89b8b342f788
Author: Russell Cattelan 
Date:   Wed May 21 14:51:19 2014 -0500

    Speed up the disk.img creation.

    Pointing makefs directly at the md mapped disk
    image is really slow. So use a temp file to create
    the file system image and then dd that directly
    to the md<>p2 partition
--- a/tools/do_gpt.sh
+++ b/tools/do_gpt.sh
@@ -1,9 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/release/scripts/doFS.sh,v 1.60 2004/08/25 01:39:52 kensmith Exp $
-#
-
-set -ex
+set -e

 FSIMG=$1
 FSPROTO=$2
@@ -41,7 +38,7 @@ fi
 echo "FSIMG ${FSIMG} FSPROTO ${FSPROTO} FSSIZE ${FSSIZE}"

 dd of=${FSIMG} if=/dev/zero count=${FSSIZE} bs=1k
-mdconfig -t vnode -f ${FSIMG}
+dd of=${FSIMG}.$$ if=/dev/zero count=${FSSIZE} bs=1k

 export unit=`mdconfig -a -t vnode -f ${FSIMG}`
 if [ $? -ne 0 ]; then
@@ -49,12 +46,16 @@ if [ $? -ne 0 ]; then
   exit 1
 fi

+set -x
 gpart create -s gpt ${unit}
 gpart add -t freebsd-boot -b 34 -l boot -s 512K ${unit}
 gpart bootcode -b ${FSPROTO}/boot/pmbr -p ${FSPROTO}/boot/gptboot -i 1 ${unit}
 gpart add -t freebsd-ufs -l rootfs ${unit}

-makefs -B little /dev/${unit}p2 ${FSPROTO}
+time makefs -B little ${FSIMG}.$$ ${FSPROTO}
+time dd if=${FSIMG}.$$ of=/dev/${unit}p2 bs=16384
+set +x
+rm ${FSIMG}.$$
 if [ $? -ne 0 ]; then
   echo "makefs failed"
   exit_with 1
@ngie-eign
Copy link
Author

Please note that ${FSIMG}.$$ also needs to be removed in do_exit.

@ngie-eign ngie-eign changed the title tools/do_gpt.sh calls makefs in an inefficient manner [PATCH] tools/do_gpt.sh calls makefs in an inefficient manner Oct 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant