Skip to content

Instantly share code, notes, and snippets.

@apevec
Created December 28, 2019 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apevec/d268601de5a0a6f35ad3859b18367b4d to your computer and use it in GitHub Desktop.
Save apevec/d268601de5a0a6f35ad3859b18367b4d to your computer and use it in GitHub Desktop.
write image file $1 to the device $2
#!/bin/bash
# write image file $1 to the device $2
if [ "${1%.gz}" = "${1}" ]; then
if [ "${1%.xz}" = "${1}" ]; then
if [ "${1%.zip}" = "${1}" ]; then
# Assuming uncompressed image for the unknown extensions
set -x
time dd if="$1" of=$2 bs=4M status=progress conv=fsync
else
set -x
time unzip -p "$1" | dd of=$2 bs=4M status=progress conv=fsync
fi
else
set -x
time xzcat "$1" | dd of=$2 bs=4M status=progress conv=fsync
fi
else
set -x
time gunzip -c "$1" | dd of=$2 bs=4M status=progress conv=fsync
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment