Premiere Bay Area Wedding Photography Blog by Trifon Anguelov Photography

1090 Clark Avenue, Mountain View, CA 94040 | (650) 930-0743 |

How To Repair Your Corrupted USB Flash Drive


Wires by Trifon Anguelov Photography  As a wedding and portrait photographer, I have been using DVD disks the last few years to deliver the final images to my clients. It was a convenient way to store up to 4.35GB of digital images and mail them. But as with technologies which change overtime,  DVD disks soon became obsolete.

With the price of USB Flash Drives dropping significantly and becoming more affordable and widespread, many computer manufacturers nowadays don’t simply add DVD disk drives to their laptops anymore. The trend has been to store and share data (including digital images) between computers with flash memory instead.

Using USB Flash drives is also more convenient. These drives are small to carry around and very sturdy in comparison to DVD disks which scratch and break easily. Not to mention to copy and read from USB Flash drives is much faster.

Recently purchased a batch of USB Flash drives for the 2015 Wedding season and after formatting and verifying all the memory sticks, found two with problems. Both were not recognized on my Windows 8 workstation so I decided to try to fix them on my MacBook Pro laptop. If you are also looking for information on how to prevent SD or CF memory cards corruption in your digital camera, this article explains in details: Five Easy Steps To Prevent Memory Card Corruption And Losing Your Photos

Here are the steps I took to repair and format them. Both are usable now and I can copy and erase digital images just fine.

First, you’ll need to figure out the disk number of the USB Flash drive. Go ahead and plug it into your Mac laptop, open new terminal window and check if the drive is recognized:

# df -k
Filesystem    1024-blocks     Used Available Capacity  iused    ifree %iused  Mounted on
/dev/disk1      117190724 50159960  66774764    43% 12603988 16693691   43%   /
/dev/disk2s1       983148      844    982304     1%        0        0  100%   /Volumes/USB #6

In this case the new device /dev/sidk2s1 has been recognized and available. In case df 0k command doesn’t give you any input, open Disk Utility application and disk out the device number for the USB Flash drive.

Next using the Disk Utility command line tool, try to verify and repair the drive by using these commands:

# diskutil info /dev/disk2
Device Identifier:        disk2
Device Node:              /dev/disk2
Part of Whole:            disk2
Device / Media Name:      General UDisk Media

Volume Name:              Not applicable (no file system)

Mounted:                  Not applicable (no file system)

File System:              None

Content (IOContent):      None
OS Can Be Installed:      No
Media Type:               Generic
Protocol:                 USB
SMART Status:             Not Supported

Total Size:               8.2 GB (8178892800 Bytes) (exactly 15974400 512-Byte-Units)
Volume Free Space:        Not applicable (no file system)
Device Block Size:        512 Bytes

Read-Only Media:          No
Read-Only Volume:         Not applicable (no file system)
Ejectable:                Yes

Whole:                    Yes
Internal:                 No
OS 9 Drivers:             No
Low Level Format:         Not supported

# diskutil verifydisk disk2

Nonexistent, unknown, or damaged partition map scheme
If you are sure this disk contains a (damaged) APM, MBR, or GPT partition
scheme, you might be able to repair it with “diskutil repairDisk disk2”

# diskutil repairdisk disk2
Nonexistent, unknown, or damaged partition map scheme
If you are sure this disk contains a (damaged) APM, MBR, or GPT partition map,
you can hereby try to repair it enough to be recognized as a map; another
“diskutil repairDisk disk2” might then be necessary for further repairs
Proceed? (y/N) y
Error repairing map: POSIX reports: Input/output error (5)

In my case as expected, both verify and repair command options failed, so it was time to bring the low level tool: gpt. This is a nice utility which will modify and recreate the disk partition table. The following commands will rewrite the partition table for /dev/disk2 to near-default (possibly a little bigger primary volume). You will need to change the /dev/disk2 with the disk number for the USB Flash drive you have before running the commands:

sudo dd if=/dev/zero of=/dev/disk2 bs=512 count=10 conv=sync,noerror
sudo gpt destroy /dev/disk2
sudo gpt create /dev/disk2
sudo gpt add -i1 -b40 -s409600 -tC12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk2
sudo gpt add -i2 -b409640 -t48465300-0000-11AA-AA11-00306543ECAC /dev/disk2

Then use Disk Utility (or preferably Disk Warrior) to repair the directory structure.

Here is the output of the above commands for my USB Flash drive I was trying to repair:

# gpt recover /dev/disk2
gpt recover: unable to open device ‘/dev/disk2’: Device not configured

# diskutil list
#:                       TYPE NAME                    SIZE       IDENTIFIER
0:      GUID_partition_scheme                        *121.3 GB   disk0
1:                        EFI EFI                     209.7 MB   disk0s1
2:          Apple_CoreStorage                         120.3 GB   disk0s2
3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
#:                       TYPE NAME                    SIZE       IDENTIFIER
0:                  Apple_HFS Macintosh HD           *120.0 GB   disk1
#:                       TYPE NAME                    SIZE       IDENTIFIER
0:                                                   *8.2 GB     disk2

# dd if=/dev/zero of=/dev/disk2 bs=512 count=10 conv=sync,noerror

10+0 records in
10+0 records out
5120 bytes transferred in 0.012109 secs (422825 bytes/sec)

# gpt destroy /dev/disk2
gpt destroy: /dev/disk2: error: device doesn’t contain a GPT

# gpt create /dev/disk2

# gpt add -i1 -b40 -s409600 -tC12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk2
/dev/disk2s1 added

# gpt add -i2 -b409640 -t48465300-0000-11AA-AA11-00306543ECAC /dev/disk2
/dev/disk2s2 added

# diskutil repairdisk disk2
Repairing the partition map might erase disk2s1, proceed? (y/N) y
Started partition map repair on disk2
Checking prerequisites
Checking the partition list
Adjusting partition map to fit whole disk as required
Checking for an EFI system partition
Checking the EFI system partition’s size
Checking the EFI system partition’s file system
Repairing the EFI system partition’s file system
Creating a new EFI system partition


Viola. The partition table was recreated and the USB Flash drives are again usable. After that you can unmount the USB Flash drive and mount it again, then use Disk Utility tool to create partition or format it.


I hope you found this article useful and helpful to solve USB Flash drives problems you might have experienced. A word of warning: The above steps would erase all data on your flash drive and would format it blank, so make sure you are OK with losing all the data before executing the commands. This approach is also not guaranteed or recommended by all USB Flash drive manufacturers, so please check and confirm before using it. I will not be liable for any lost of data or damages you might experience by using the above steps.

If you USB Flash drive contains data and you are trying to recover digital files from it, but the drive cannot be recognized at all, then consider these memory card and USB Flash Drive recovery tools and services: How To Recover Photos From Memory Card

About the Author:

Trifon Anguelov Photography is a Premiere Bay Area Wedding and Events Photography business  based in Mountain View, CA 94040 and serving clients in San Francisco Bay Area. You can read more about the author and follow his work on his Bay Area Wedding Photography Site


Author: Trifon Anguelov

Photographer in San Francisco Bay Area, California. Currently based in Mountain View, California, I am specializing in portraiture and events photography. Working with clients to fulfill their needs for personal and business, headshots, children portraits, family portraits, corporate headshots and portraits, commercial photography and events photography. In my free time I also enjoy photography landscapes and wildlife.

15 thoughts on “How To Repair Your Corrupted USB Flash Drive

  1. Regular reader. This is detailed and useful. Bookmarked it already.


  2. Very Informative & Interesting post.
    Thanks for sharing.
    It’s very helpful for me.

    Liked by 1 person

  3. Pingback: Five Easy Steps to Prevent Memory Card Corruption and Losing Your Photos | Premiere Bay Area Wedding Photography Blog by Trifon Anguelov Photography

  4. Pingback: How To Recover Photos from Memory Card | Premiere Bay Area Wedding Photography Blog by Trifon Anguelov Photography

  5. I am happy I found this article on Google. Had the very same problem and following your steps was able to repair my USB drive with wedding images. All files are readable now.

    Thanks a ton!

    Liked by 1 person

  6. Absolutely love your blog. Have been searching for a while and I am glad I found your blog. You nailed the topic. Thank you for sharing your knowledge.

    Liked by 1 person

  7. Greetings! This is my first visit to your wedding photography blog! Your blog provided me with good insights and I enjoyed reading it. You have done a wonderful job! Will be coming back for more information. Way to go partner.

    Liked by 1 person

  8. I’m really enjoying the design and layout of your site. it is easy to navigate and no clutter whatsoever. Exceptional work!

    Did you hire out a developer to create your theme or used one of the free WordPress themes? I am looking to start my own blog so any links to themes would be very helpful. And the information you are posting is a quality work. Keep it up!

    Liked by 2 people

    • Appreciate your comment. I did used WordPress theme already created by someone. Finding it hard to allocate time to create my own theme. There are so many available that I suggest to try to search and see if any of the available ones match your taste. Simple search on Google for “WordPress themes) should do.


  9. Appreciate this post as this was the only post with advanced Terminal commands I found on internet today. Though my external HDD was corrupt it couldn’t go beyond “Creating a new EFI system partition” and returned with an error.

    Thanks for this article. This let me go beyond what Disk Util could do.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s