Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Wipe linux device with progress bar
#!/bin/bash
# resource
# https://wiki.archlinux.org/index.php/Securely_wipe_disk
dev="/sys/block/sda"
sector_number=$(cat ${dev}/size)
sector_size=$(cat ${dev}/queue/logical_block_size)
size=$((${sector_number} * ${sector_size}))
# Fast wipe
echo "dd if=/dev/zero | pv --size ${size} | dd seek=0 of=${dev} bs=${block_size} count=${block_count} oflag=\"direct\""
# Wipe with random, should avoid data remanence for paranoïds
echo "dd if=/dev/urandom | pv --size ${size} | dd seek=0 of=${dev} bs=${block_size} count=${block_count} oflag=\"nocache\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment