Skip to content

Instantly share code, notes, and snippets.

@Gargravarr2112
Created May 11, 2018 14:42
Show Gist options
  • Save Gargravarr2112/29f88caf1f511012839eb27e1bd5c0e5 to your computer and use it in GitHub Desktop.
Save Gargravarr2112/29f88caf1f511012839eb27e1bd5c0e5 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -eu;
inputFile="$1";
if [ ! -f "$1" ]; then
echo "$1 is not a file!";
exit 1;
fi
outputDevice="$2";
if [ ! -b $outputDevice ]; then
echo "$2 is not a block device!";
exit 1;
fi
imageSizeBytes=$(ls --size --block-size=1 "$inputFile" | awk '{print $1}');
dd if="$inputFile" | pv -bpaerts $imageSizeBytes | sudo dd of=$outputDevice;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment