Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to restore unreadable USB flash drive under Mac OS X
1. Open Terminal and go to /dev
$ cd /dev
2. Now it’s time to find your flash drive in /dev. Typically it’s /dev/diskN where N could be 0, 1, 2, 3, etc
$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk3
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *8.1 GB disk3
1: EFI 209.7 MB disk3s1
2: Microsoft Basic Data KB 7.9 GB disk3s2
OK! It’s disk number 3, i.e. /dev/disk3 Remember the name of partition (it’s KB in my case). Your flash drive is mounted as /Volumes/NAME
3. Let’s erase and reformat the disk. In 90% you will get a message that the system can’t unmount your drive.
$ diskutil eraseDisk MS-DOS KB /dev/disk3
Started erase on disk3
Unmounting disk
Error: -69888: Couldn't unmount disk
Use the partition name from step 2.
$ diskutil unmountDisk force /Volumes/KB
Forced unmount of all volumes on disk3 was successful
$ diskutil eraseDisk MS-DOS KB /dev/disk3
Started erase on disk3
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk3s2 as MS-DOS (FAT) with name KB
512 bytes per physical sector
/dev/rdisk3s2: 15377032 sectors in 1922129 FAT32 clusters (4096 bytes/cluster)
bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=411648 drv=0x80 bsec=15407104 bspf=15017 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk3
That’s all. Now you have a USB flash drive again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.