#!/bin/bash
[ -z "$1" ] &&
{
	echo "need argument 1:  64MB chunk to start from"
	exit 1
}
n=$1
kbyte=0
t0=$( date +%s )
while true
do
	skip=$(( n * 1024 ))
	byte=$(( n * 67108864 ))
	mbyte=$(( byte / ( 1024 * 1024 ) ))
	kbyte=$(( kbyte + 65536 ))
	t1=$( date +%s )
	td=$(( t1 - t0 ))
	[ $td -gt 0 ] || td=1
	kbps=$(( kbyte / td ))
	echo -ne "it $n, skip $skip, mb $mbyte, kbps $kbps   "
	dd if=/dev/sda of=/dev/shm/ddblk bs=64k count=1024 skip=$skip 2>/dev/null || break
	cmp /dev/shm/ddblk /dev/zero 2>&1 |
	grep -q 'zero differ: char ' &&
	{
		echo -ne "blanking"
		dd if=/dev/zero of=/dev/sda bs=64k count=1024 seek=$skip 2>/dev/null
	}
	echo
	n=$(( n + 1 ))
done

