[tyndur-devel] [PATCH 1 of 2] build: dd if='/dev/zero' ... ist zu langsam
Andreas Freimuth ·
* Beim Erstellen von leeren Images auf dd verzichten, statt dessen ein kleines Python-Script verwenden Signed-off-by: Andreas Freimuth <m.nemo at gmx.net> --- build/scripts/empty_file | 24 ++++++++++++++++++++++++ build/scripts/image_cdrom | 2 +- build/scripts/image_floppy | 2 +- build/scripts/image_hd | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/build/scripts/empty_file b/build/scripts/empty_file new file mode 100755 --- /dev/null +++ b/build/scripts/empty_file @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +# Eine leere Datei mit einer bestimmten Größe erzeugen +# Parameter: +# 1. Dateiname +# 2. Dateigröße +import sys + +def empty_file(filename, size): + f = open(filename,"wb") + if not f: + sys.exit(1) + + f.seek(size - 1) + f.write('\0') + f.close() + +if __name__ == "__main__": + if len(sys.argv[1:]) != 2: + print sys.stderr, "using: %s <filename> <size>" % sys.argv[0] + sys.exit(1) + + empty_file(str(sys.argv[1]), int(sys.argv[2])) diff --git a/build/scripts/image_cdrom b/build/scripts/image_cdrom --- a/build/scripts/image_cdrom +++ b/build/scripts/image_cdrom @@ -96,7 +96,7 @@ EOF NEW=0 if ! [ -f $FLOPPY_IMAGE_PATH ]; then # Leeres Image erstellen und formatieren - dd if=/dev/zero of=$FLOPPY_IMAGE_PATH bs=1024 count=1440 + build/scripts/empty_file $FLOPPY_IMAGE_PATH $((1024 * 1440)) mformat l: NEW=1 fi diff --git a/build/scripts/image_floppy b/build/scripts/image_floppy --- a/build/scripts/image_floppy +++ b/build/scripts/image_floppy @@ -58,7 +58,7 @@ EOF NEW=0 if ! [ -f $IMAGE_PATH ]; then # Leeres Image erstellen und formatieren - dd if=/dev/zero of=$IMAGE_PATH bs=1024 count=1440 + build/scripts/empty_file $IMAGE_PATH $((1024 * 1440)) mformat l: NEW=1 fi diff --git a/build/scripts/image_hd b/build/scripts/image_hd --- a/build/scripts/image_hd +++ b/build/scripts/image_hd @@ -57,7 +57,7 @@ die() NEW=0 if ! [ -f $IMAGE_PATH ]; then # Leeres Image erstellen und formatieren - dd if=/dev/zero of=$IMAGE_PATH bs=$((1024*1024)) count=$IMAGE_SIZE 2> /dev/null + build/scripts/empty_file $IMAGE_PATH $(($IMAGE_SIZE * 1024 * 1024)) build/scripts/create_partition $IMAGE_PATH NEW=1 fi @@ -70,7 +70,7 @@ PART_SIZE=`echo $PARTITIONS | awk '{prin if [ $NEW -ne 0 ]; then PART_IMAGE=`mktemp` - dd if=$IMAGE_PATH of=$PART_IMAGE bs=512 skip=$PART_START count=$PART_SIZE + build/scripts/empty_file $PART_IMAGE $(($PART_SIZE * 512)) # Dateisystem erstellen $LOST_TOOLS_MKE2FS -F -q $PART_IMAGE || die "Dateisystem konnte nicht erstellt werden"