User Tools

Site Tools


disks

Disks

Overwrite empty space with nulls

Write Write nulls to free space of all partitions on /dev/sda

cleandisk
#!/bin/bash
## fill empty space with nulls to really delete everything
 
sfdisk -d /dev/sda \
| awk '/^.dev.sd/ {print $1}' \
| while read d; do
    mkdir -p /mnt/x
    mount $d /mnt/x
    ls -l /mnt/x
    echo "writing nulls to free space on $d ..."
    time cat /dev/zero > /mnt/x/zeroes
    sync
    rm /mnt/x/zeroes
    umount /mnt/x
  done
echo OK

ddrescue

disk=/dev/sdx
image=/mnt/temp/sdx.img
log=/mnt/temp/ddrescue-sdx.log
 
# first pass
ddrescue -f -n $disk "$log" "$image" "$log"
 
# now retry harder
ddrescue -d -f -r3 $disk "$log" "$image" "$log"

Options:

  • -d, --idirect : use direct disc access for input file
  • -f, --force : overwrite output device or partition
  • -n, --no-scrape : skip the scraping phase
  • -r, --retry-passes=<n> : exit after <n> retry passes (-1=infinity) [0]
/docs/dokuwiki/data/pages/disks.txt · Last modified: 2024-05-25 11:39:03 by mi