#!/bin/bash # just a script to help with some disk rescue that involves cd writing # # constants # edit these to suit # disk info in MB, where 1MB = 1024*1024 bytes = 1048576 bytes diskend=24380 chunk=660 # which disk disk=/dev/hdd # get a name for dd's output, tail of $disk above, # to be combined with the count later fname=/dev/hdb5 # blocksize, in bytes, used in dd # 1MB (1024 * 1024) is chosen here block=1048576 # bytes in a sector sector=512 # sectors per block secb=$((${block} / ${sector})) numchunks=$(($(echo "${diskend} / ${chunk}" | bc ) + 1)) # counters skip=0 cnt=0 while [ ${cnt} -lt ${numchunks} ] do start=$((${cnt} * ${chunk})) end=$((${start} + ${chunk})) if [ ${end} -gt ${diskend} ] then chunk=$((chunk - (${end} - ${diskend}))) end=$((${diskend})) fi fpre=$((${cnt}+1)) if [ ${fpre} -lt 100 ] then fpre=0${fpre} fi if [ ${fpre} -lt 10 ] then fpre=0${fpre} fi secst=$((${start} * ${secb})) secen=$((${end} * ${secb})) echo "${fpre} dd if=${disk} of=${fname} bs=${block} skip=0 seek=${skip} count=${chunk}" echo " (start=${start}MB, ${secst}s, end=${end}MB, ${secen}s)" skip=$((${skip} + ${chunk})) cnt=$((${cnt} + 1)) done echo "chunks=${numchunks}"