rm $2 truncate -r $1 $2 filefrag -v $1 | grep -v "File" | grep -v " ext logical physical expected length flags" | grep -v "extents found" | while read ext logical physical expected length flags; do [ -z $logical ] && continue [ -z $length ] && length=$expected [ -z $length ] && continue hole_jump="" if [ "$length" != "0" ]; then hole_jump="seek=$logical skip=$logical conv=notrunc" fi dd if=$1 of=$2 \ count=$length bs=4096 \ iflag=fullblock oflag=direct,dsync \ $hole_jump \ 2> /dev/null done filefrag -v $2 cmp $1 $2