Created
March 31, 2017 22:51
Revisions
-
jpouellet created this gist
Mar 31, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #!/bin/bash if [ $# -eq 0 ]; then dev=/dev/sda else # Protected by arg-specific qubes-rpc policy. dev=/dev/"$1" fi if ! [ -b "$dev" ]; then echo "${0##*/}: $dev: No such block device" >&2 exit 1 fi # Keep track of exactly how much we wrote to know where to stop reading later. len=$(sudo tee -- "$dev" | wc -c) echo "${0##*/}: Done writing $len bytes to $dev. Verifying..." >&2 # Read it back from actual media, only once, passing it to all checksums. # Wait for all hashes to be done, and guarantee consistent ordering. sudo head -c "$len" -- "$dev" | ( tee >(sha1sum --tag) >(sha256sum --tag) > >(sha512sum --tag) ) | sort