Skip to content

Instantly share code, notes, and snippets.

@mgherghi
Forked from joeblau/OSX Secure Disk Wipe.md
Created April 25, 2019 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgherghi/ddc7ffb74ad8929828c8ee7df5d82bf0 to your computer and use it in GitHub Desktop.
Save mgherghi/ddc7ffb74ad8929828c8ee7df5d82bf0 to your computer and use it in GitHub Desktop.
Securely erase an external disk using dd on OSX

Securely erase an external disk using dd on OSX

  1. Plug in your SD card, HDD, or other block device and then use the following command to see which /dev/diskN node it's located on:
diskutil list
  1. Unmount the disk where “N� is the number of the disk taken from the above command:
diskutil unmountDisk /dev/diskN

If the above command was successful, you will see:

Unmount of all volumes on diskN was successful

  1. Execute dd command as super user on disk where "N" is the number of the disk from step 1.
sudo dd if=/dev/urandom of=/dev/diskN bs=1000000

This will overwrite all partitions, master boot records, and data. Please note that this may take a while depending on the size of your disk and there is no progress indicator. However; If you want to check whether or not dd is working you can always use pv (Available on Homebrew) which will dump out the raw data being written to the disk.

sudo pv /dev/disk1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment