Created
November 28, 2012 07:14
-
-
Save samba/4159581 to your computer and use it in GitHub Desktop.
Compressed disc image restoration with "threading"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Assumes images are broken out into 1024mb chunks, separately gzipped, | |
# stored as ./image/image.X.blob.gz, where X is an integer (0...). | |
# Decompresses and writes 6 in parallel (i.e. threading) since Gzip is slow. | |
DEVICE=$1 | |
sectionsize=1024 | |
maxthreads=5 | |
curthreads=0 | |
set -x | |
for i in `seq 0 2786`; do | |
blockcount=$(( sectionsize * i )) | |
zcat image/image.$i.blob.gz | dd of=$DEVICE bs=1M count=${sectionsize} seek=${blockcount} iflag=fullblock & | |
if [ $maxthreads -eq $curthreads ]; then | |
curthreads=0 | |
wait | |
else | |
curthreads=$(( curthreads + 1 )) | |
fi | |
done | |
set +x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment