Skip to content

Instantly share code, notes, and snippets.

@copremesis
Forked from joeblau/OSX Secure Disk Wipe.md
Last active August 13, 2020 04:08
Show Gist options
  • Save copremesis/19c2824d8fe7db12033ed7dd6decfc33 to your computer and use it in GitHub Desktop.
Save copremesis/19c2824d8fe7db12033ed7dd6decfc33 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