- 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
- 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
- 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/rdiskN bs=1m
This will overwrite all partitions, master boot records, and data.
Please note that this may take a while depending on the size and speed of your disk and there is no progress indicator. However, if you want to check progress, on Mac you can use CTRL + T
.
This is equivalent to
sudo diskutil zeroDisk /dev/rdiskN.
If you want true secure erase then use:
diskutil secureErase [freespace] level MountPoint|DiskIdentifier|DeviceNode
Securely erases either a whole disk or a volume's freespace.
Level should be one of the following:
0 - Single-pass zeros.
1 - Single-pass random numbers.
2 - US DoD 7-pass secure erase.
3 - Gutmann algorithm 35-pass secure erase.
4 - US DoE 3-pass secure erase.