Created
January 28, 2018 23:15
-
-
Save countingpine/9cac455546b60940fd76bd3c3df4f870 to your computer and use it in GitHub Desktop.
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 characters
| #!/bin/bash | |
| # sha256sum each (megabyte-sized) block of /dev/sda, prepend the block number | |
| # intent is to compare two drivesum lists and then dd out the changed blocks and send them to the other drive | |
| device=/dev/sda | |
| bs=1048576 | |
| size=$(blockdev --getsize64 $device) | |
| sumsfile=/tmp/sums_$(date +%s).txt | |
| blocks=$(( ($size+$bs-1)/$bs )) | |
| #test: blocks=10 | |
| for ((i = 0; i < $blocks; i++)); do | |
| dd if=/$device bs=$bs skip=$i count=1 status=none | sha256sum | |
| done | awk '{print n+0, $1; n++}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment