Skip to content

Instantly share code, notes, and snippets.

@sstolz
Created January 12, 2017 09:53
Show Gist options
  • Save sstolz/363a5754c159f6d2bff9db260547c061 to your computer and use it in GitHub Desktop.
Save sstolz/363a5754c159f6d2bff9db260547c061 to your computer and use it in GitHub Desktop.
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