Skip to content

Instantly share code, notes, and snippets.

@DutchEllie
Created November 10, 2023 10:39
Show Gist options
  • Save DutchEllie/a9860d52b06f7d826fca8fd6c830eec9 to your computer and use it in GitHub Desktop.
Save DutchEllie/a9860d52b06f7d826fca8fd6c830eec9 to your computer and use it in GitHub Desktop.
We partake in a minuscule amount of tomfoolery
#!/bin/bash
num_bytes=$1
num_places=$2
disk="/dev/sda" # You can change this to your own disk
disk_size=$(blockdev --getsize64 "$disk")
effective_disk_size=$(($disk_size - $num_bytes))
for ((i=0; i<num_places; i++)); do
offset=$(shuf -i 0-$effective_disk_size -n 1)
dd if=/dev/urandom of="$disk" bs=1 count="$num_bytes" seek="$offset" conv=notrunc
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment