Skip to content

Instantly share code, notes, and snippets.

@garethrees
Created April 28, 2020 15:32
Show Gist options
  • Save garethrees/7b67db37c43415720da920499ab7231c to your computer and use it in GitHub Desktop.
Save garethrees/7b67db37c43415720da920499ab7231c to your computer and use it in GitHub Desktop.
Format USB drive from the command line macOS
diskutil list
diskutil unmountDisk /dev/disk2
diskutil eraseDisk FAT32 SANDISK /dev/disk2
@rameshkpatra
Copy link

Hi,
It worked. Thank you so much.

@Pradeeparul2
Copy link

It's working, Thanks.

@Bugerman58
Copy link

Tnx! It's working method!🔥👍

@anuj-kumar-r
Copy link

anuj-kumar-r commented Sep 2, 2024

Thankyou soo much, the disk utility cannot fix the issue.
the commands fixed it.

@sbmaggarwal
Copy link

sbmaggarwal commented Sep 22, 2024

It's working, Thanks. To add secure erase config, we can use it like:

sudo diskutil secureErase 4 eraseDisk exFAT sandisk128 /dev/disk9

@laurajaime
Copy link

thanks!!! you saved my day

@Delspa1
Copy link

Delspa1 commented Nov 17, 2024

I need your help. It seems that my 128Gig SanDisk memory card has an internal write protection on and I cant erase anything on it. My MAC disk utility wont work, the adapter security switch doesnt help, it is locked on a software side of the SD Micro card.
Can yoiu help. I use a MAC and dont have a lot of experience with the Terminal side.

@zencd
Copy link

zencd commented Jan 10, 2025

unmountDisk is not required in practice, Sequoia.

@hantv15
Copy link

hantv15 commented Mar 10, 2025

Thank you, It's works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment