Kaynağa Gözat

really really clean a disk

master
Coesens Bert 10 ay önce
ebeveyn
işleme
ec073aac0e
1 değiştirilmiş dosya ile 30 ekleme ve 0 silme
  1. +30
    -0
      reallycleandisk.sh

+ 30
- 0
reallycleandisk.sh Dosyayı Görüntüle

@@ -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

Yükleniyor…
İptal
Kaydet