Created
August 27, 2012 15:41
-
-
Save samba/3489640 to your computer and use it in GitHub Desktop.
DD Imaging util
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 | |
# usage: | |
# sudo dd-local-monitor.sh if=/dev/sda bs=24M | gzip > /mnt/external/myimage.blob.gz | |
main () { | |
echo "# dd: $@" >&2 | |
dd $@ & | |
DDPID=$! | |
while ps $DDPID >/dev/null; do | |
kill -USR1 $DDPID || break | |
sleep 10 | |
done | |
} | |
main "$@" |
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 | |
# arg 1: start index (default 0) | |
# arg 2: end index (default 20000) | |
REMOTE=root@remote-server | |
REMOTE_DEVICE=/dev/sda | |
OUTPUT=/mnt/external/images/0 | |
mkdir -p $OUTPUT | |
sectionsize=1024 | |
for i in `seq ${1:-0} ${2:-20000}`; do | |
blockcount=$(( sectionsize * i )); | |
command="dd if=${REMOTE_DEVICE} bs=1M count=${sectionsize} skip=${blockcount} | gzip" | |
echo "# section $i (skip $blockcount) command: ${command}" | |
ssh $REMOTE "${command}" > ${OUTPUT}/image.$i.blob.gz || break | |
done |
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 | |
# arg 1: start index (default 0) | |
# arg 2: end index (default 20000) | |
REMOTE=root@remote-server | |
REMOTE_DEVICE=/dev/sda | |
INPUT=/mnt/external/images/0 | |
sectionsize=1024 | |
for i in `seq ${1:-0} ${2:-20000}`; do | |
blockcount=$(( sectionsize * i )); | |
command="gzip -cd | dd of=${REMOTE_DEVICE} bs=1M count=${sectionsize} seek=${blockcount}" | |
echo "# section $i (skip $blockcount) command: ${command}" | |
cat ${INPUT}/image.$i.blob.gz | ssh $REMOTE "${command}" || break | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment