Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing md5sum for speeding up dd disk imaging, sample script: Good idea?
    text
    copied!<p>I was thinking of ways to have my laptop HDD backed up safely, and still being able to put the backup rapidly in use if needed. My method would be the following: I would buy an 2.5" HDD of the same size with USB to SATA cable and clone the internal to it, when disaster strikes, I would just have to swap the HDD in the laptop for the other one and I would be good to go again. However, I would like to avoid writing 500GB each time I want to backup my HDD, especially when I know that a fair part of it (+/- 80GB) is rarely written to, this is where the following md5sum/dd script comes to the rescue, I hope:</p> <pre><code>#!/bin/bash block="1M" end=50000 count=10 input="/dev/sda" output="/dev/sdb" output="/path/to/imagefile" function md5compute() { dd if=$1 skip=$2 bs=$block count=$count | md5sum - | awk '{ print $1 }' } for i in {0..$end} do start=$(($i*$count)) md5source=$(md5compute $input $start) md5destination=$(md5compute $output $start) if [ "$md5source" != "$md5destination" ] then dd if=$input of=$output skip=$start seek=$start count=$count conv=sync,noerror,notrunc fi done </code></pre> <p>Now, the question part:</p> <p>A) With running this, would I miss some part of the disk? Do you see some flaws?</p> <p>B) Could I win some time compared to the 500GB read/write?</p> <p>C) Obviously I potentially write less to the target disk. Will I improve the lifetime of that disk?</p> <p>D) I was thinking of leaving count to 1, and increasing the block size.Is this good idea/bad idea?</p> <p>E) Would this same script work with an image file as output?</p> <p>Not being very fluent in programming, there should be plenty of room for improvement, any tips?</p> <p>Thank you all...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload