Sfoglia il codice sorgente

really really clean a disk

master
Coesens Bert 11 mesi fa
parent
commit
ec073aac0e
1 ha cambiato i file con 30 aggiunte e 0 eliminazioni
  1. +30
    -0
      reallycleandisk.sh

+ 30
- 0
reallycleandisk.sh Vedi File

@@ -0,0 +1,30 @@
#!/usr/bin/bash
set -x

DISK=${1:-nodisk}

if [ "x${DISK}" = "xnodisk" ]; then
echo "What disk ? (sda, sdb, nvme0n1,...)"
exit 1
fi

SIZE=$(sudo blockdev --getsz /dev/${DISK})
PBSZ=$(sudo blockdev --getpbsz /dev/${DISK})
SEEK=$(($SIZE - 256 * 1024 * 2 / $PBSZ))
LEN=$((256 *2 *1024 /$PBSZ))
# SEEK=$(( $(sudo blockdev --getsz "/dev/sdX1") - 256 * 1024 * 2 / $(sudo blockdev --getpbsz "/dev/sdX1")))
echo $SIZE $PBSZ $SEEK $LEN
for i in 1 2 3 4 ; do
TOWIPE=${DISK}${i}
if [ -b /dev/$TOWIPE ] ; then
sudo wipefs -a -f /dev/${TOWIPE}
sudo dd if=/dev/zero of=/dev/${TOWIPE} bs=$PBSZ count=$LEN
sudo dd if=/dev/zero of=/dev/${TOWIPE} seek=$SEEK bs=$PBSZ count=$LEN
fi
done



sudo wipefs -a -f /dev/${DISK}
sudo dd if=/dev/zero of=/dev/${DISK} bs=$PBSZ count=$LEN
sudo dd if=/dev/zero of=/dev/${DISK} seek=$SEEK bs=$PBSZ count=$LEN

Caricamento…
Annulla
Salva