Thank you to Halfgaar for directing me to badblocks. That was the ideal path to what I wanted to achieve.
For my home desktop context, this task done this way would take about 54+ hours, non-stop.
I include here the script I built to address my needs. Explanations as to the WHYs are included in the script.
#!/bin/sh
BASE=`basename "$0" ".sh" `
TRACKER=./${BASE}.last
SLICE=`expr 4096 \* 16 `
echo "\n\t This utility will overwrite the full disk with all data bits ON\n\t using '0xFFFF' as test pattern for destructive badblocks scan ..."
echo "\n\t This utility will begin at the last sector and work its way towards the first sector\n\t on the disk, doing slices of ${SLICE} sectors at one time ..."
echo "\n\t The design concept is based on fact that some older USB-attached devices\n\t have both slow interface and slow disk I/O, as well as taking into account\n\t the End-User context of a Desktop computer which cannot remain up and running\n\t for 2-3 days non-stop. The process can be interrupted at any time and\n\t the script will be able to restart at the last known completed segment\n\t to continue from there."
if [ "$1" != "--force" ]
then
echo "\n\n\t As a security precaution, you MUST review the script to ensure proper\n\t understanding of DANGERS AND RISKS before proceeding.\n Bye!\n" ; exit 1
fi
echo "\n\t Enter disk (block) device path (i.e. /dev/sdb) => \c" ; read DISK
if [ -z "${DISK}" ] ; then echo "\n\t No path entered for a block device. Cannot proceed.\n Bye!\n" ; exit 1 ; fi
if [ ! -b "${DISK}" ] ; then echo "\n\t '${DISK}' is not an existing block device file. Cannot proceed.\n Bye!\n" ; exit 1 ; fi
testor=`df | grep ${DISK} | head -1 `
if [ -n "${testor}" ] ; then echo "\n\t Mounted partitions for that device:" ; echo "${testor}" | awk '{ printf("\t\t %s\n", $0 ) ; }' ; echo " Bye!\n" ; exit 1 ; fi
### Disk /dev/sdd: 149.5 GiB, 160041885696 bytes, 312581808 sectors
SECTORS_LGCL=`fdisk -l ${DISK} | grep '^Disk '${DISK} | awk '{ print $7 }' `
echo "${SECTORS_LGCL}" | awk '{ printf("\t SECTORS_LOGICAL = %12s\n", $0 ) ; }'
### Sector size (logical/physical): 512 bytes / 4096 bytes
SECT_SIZE_LGCL=`fdisk -l ${DISK} | grep '^Sector size' | awk '{ print $4 }' `
SECT_SIZE_PSCL=`fdisk -l ${DISK} | grep '^Sector size' | awk '{ print $7 }' `
CLUMPING=`expr ${SECT_SIZE_PSCL} / ${SECT_SIZE_LGCL} `
SECTORS_PSCL=`expr ${SECTORS_LGCL} / ${CLUMPING} `
echo "${SECTORS_PSCL}" | awk '{ printf("\t SECTORS_PHYSICAL = %12s\n", $0 ) ; }'
LAST_TODO=0
LAST=`expr ${SECTORS_PSCL} - 1 `
ITERATION=`expr ${LAST} - ${SLICE} + 1 `
COUNT=`expr ${SECTORS_PSCL} / ${SLICE} `
if [ -s ${TRACKER} ]
then
read ITERATION <${TRACKER}
ITERATION=`expr ${ITERATION} - ${SLICE} `
echo "\t Using last known good ITERATION captured before last abandon ..."
COUNT=`expr ${ITERATION} - 1 ` ; COUNT=`expr ${COUNT} / ${SLICE} `
fi
echo "\t Iteration countdown from $COUNT ..."
while [ ${ITERATION} -ge ${LAST_TODO} ]
do
echo "${COUNT} ${ITERATION} ${SECTORS_PSCL}" | awk '{ printf("\n\n[%s] Slice 1st sector = %12s / %s ...\n", $1, $2, $3 ) ; }'
ITERATION_LAST=`expr ${ITERATION} + ${SLICE} - 1 `
if [ ${ITERATION_LAST} -gt ${SECTORS_PSCL} ]
then
ITERATION_LAST=`expr ${SECTORS_PSCL} - 1 `
ITERATION=`expr ${ITERATION_LAST} - ${SLICE} `
fi
echo "${ITERATION_LAST}" | awk '{ printf("\tITERATION_LAST = %12s\n", $0 ) ; }'
echo "${SLICE}" | awk '{ printf("\tSLICE = %12s\n", $0 ) ; }'
echo "${ITERATION}" | awk '{ printf("\tITERATION = %12s\n", $0 ) ; }'
badblocks -v -s -w -b ${SECT_SIZE_PSCL} -p 0 -e 0 -t 0xFFFF /dev/sdd ${ITERATION_LAST} ${ITERATION}
echo "${ITERATION}" >${TRACKER}
if [ ${ITERATION} -eq ${LAST_TODO} ]
then
break
else
ITERATION=`expr ${ITERATION} - ${SLICE} `
if [ ${ITERATION} -lt ${LAST_TODO} ]
then
ITERATION=${LAST_TODO}
fi
fi
COUNT=`expr ${COUNT} - 1 `
done
exit
The session output (after re-starting) looks like this:
This utility will overwrite the full disk with all data bits ON
using '0xFFFF' as test pattern for destructive badblocks scan ...
This utility will begin at the last sector and work its way towards the first sector
on the disk, doing slices of 65536 sectors at one time ...
The design concept is based on fact that some older USB-attached devices
have both slow interface and slow disk I/O, as well as taking into account
the End-User context of a Desktop computer which cannot remain up and running
for 2-3 days non-stop. The process can be interrupted at any time and
the script will be able to restart at the last known completed segment
to continue from there.
Enter disk (block) device path (i.e. /dev/sdb) => /dev/sdd
SECTORS_LOGICAL = 312581808
SECTORS_PHYSICAL = 312581808
Using last known good ITERATION captured before last abandon ...
Iteration countdown from 4712 ...
[4712] Slice 1st sector = 308846247 / 312581808 ...
ITERATION_LAST = 308911782
SLICE = 65536
ITERATION = 308846247
Checking for bad blocks in read-write mode
From block 308846247 to 308911782
Testing with pattern 0xffff: done
Reading and comparing: done
Pass completed, 0 bad blocks found. (0/0/0 errors)
[4711] Slice 1st sector = 308780711 / 312581808 ...
ITERATION_LAST = 308846246
SLICE = 65536
ITERATION = 308780711
Checking for bad blocks in read-write mode
From block 308780711 to 308846246
Testing with pattern 0xffff: done
Reading and comparing: done
Pass completed, 0 bad blocks found. (0/0/0 errors)
***