Is your memory card or pendrive asking to be formatted?

It might show up as RAW, or not open at all. A corrupted memory card is one of the worst things that can happen, especially when your photos are on it.

The quick answer: start with chkdsk, which fixes file system errors without erasing anything. If the files on the card matter to you, recover them before you format.

I first wrote this guide in 2015, with a single set of diskpart commands. Those commands still work, but they erase everything on the card.

This updated guide covers the safe fixes first, how to get your files back, and only then how to wipe and repair the card. It works for SD cards, microSD cards and USB pendrives.

Also Read: How to Make a Bootable USB Using Command Prompt (Windows 11)

TL;DR

  • Try chkdsk first: run chkdsk E: /f in an administrator Command Prompt. It repairs file system errors and doesn't erase anything.
  • Recover your files before you format: if the card is asking to be formatted, use Windows File Recovery first. Formatting erases everything on the card.
  • Format with Disk Management or diskpart: choose FAT32 for cards of 32 GB or less, and exFAT for bigger ones. Double-check the disk before you type clean.
  • On a Mac: run First Aid in Disk Utility first, and only erase the card if you need to.

Why Do Memory Cards Get Corrupted?

Viruses and malware can damage a card, but they're not the usual cause. In the 2015 version, I blamed them.

More often, it's one of these:

  • Pulling out the card or pendrive while files are still being copied.
  • A phone or camera switching off while it's saving to the card.
  • An old, worn-out card. Flash memory doesn't last forever.
  • A cheap or fake card that's smaller than it claims to be.
  • Physical damage, like a cracked card or bent USB connector.

Recover Your Files Before You Format

Some of the fixes below, like Format, clean and New Simple Volume, erase everything on the card.

If there are photos or documents on it that you care about, try to recover them first. Even Microsoft's own troubleshooting guide says not to format a drive if you're trying to recover files from it.

Until you've got your files back, don't copy anything new onto the card.

Quick Checks Before You Start

These sound too simple, but they fix a surprising number of "dead" cards:

  1. Try a different USB port, preferably one directly on your PC, not on a hub.
  2. Try a different card reader or adapter.
  3. Try the card in another computer.
  4. For SD cards, check the small lock switch on the side and slide it to the unlocked position.

Repair Methods at a Glance

MethodErases the card?Works onBest for
chkdsk (Method 1)NoWindowsFile system errors
Windows File Recovery (Method 2)No, it copies files offWindows 10 and 11Getting photos and files back
Disk Management (Method 3)YesWindowsFormatting a RAW or unallocated card
diskpart (Method 4)YesWindowsCards that Disk Management can't format
SD Memory Card Formatter (Method 5)YesWindows and MacSD and microSD cards
Disk Utility (Mac)First Aid: no. Erase: yesMacMac users

How to Fix Errors with chkdsk (Doesn't Erase Anything)

This is the first real fix to try. It checks the card for file system errors and repairs them.

  1. Plug in your memory card or pendrive and note its drive letter in File Explorer. I'll use E:.
  2. Search for "Command Prompt" in the Start menu, right-click it and choose "Run as administrator".
  3. Type this and press Enter:
chkdsk E: /f

The /f part tells it to fix the errors it finds.

If you think the card has bad sectors, use /r instead. It does everything /f does and also tries to read data from damaged areas, but it takes much longer:

chkdsk E: /r

My advice: run /f first, and only use /r if that doesn't fix the card.

If chkdsk asks whether to convert lost chains to files, press Y. Any pieces it rescues are saved in the main folder of the card as files with names like File0000.chk.

How to Recover Files with Windows File Recovery

If chkdsk didn't help, or the card is asking to be formatted, get your files off it before you go further.

Microsoft has a free command-line tool for this called Windows File Recovery. You can get it from the Microsoft Store, and it works on Windows 10 and Windows 11.

For SD cards and pendrives, which usually use FAT32 or exFAT, Microsoft says to use Extensive mode.

  1. Install Windows File Recovery from the Microsoft Store.
  2. Search for "Windows File Recovery" in the Start menu, open it, and select "Yes" when Windows asks for permission. A Command Prompt window opens.
  3. Type a command like this one, which looks for photos and videos on E: and saves them to C::
winfr E: C: /extensive /n *.jpg /n *.mp4

The source and destination must be different drives, so never recover files onto the same card.

Windows creates a folder called Recovery_ followed by the date and time on your C: drive, and puts the recovered files there.

Also Read: How to Use the Recycle Bin on Your Android (No App Needed)

How to Format a Memory Card with Disk Management

Got your files back, or was there nothing important on it? Now you can repair the card by formatting it.

Warning: this erases everything on the card.

  1. Right-click the Start button and choose "Disk Management".
  2. Find your card by its size. Be careful to pick the right one.
  3. If the partition shows as RAW, right-click it and choose "Format".
  4. If it shows as Unallocated, right-click it and choose "New Simple Volume", then follow the steps.
  5. For the file system, choose FAT32 for cards of 32 GB or less, and exFAT for anything bigger.

If your card doesn't show up at all, unplug it, plug it back in, and click "Action" → "Rescan Disks".

How to Repair a Memory Card with diskpart (the 2015 Method, Updated)

This is the method from my original post. Use it when Disk Management can't format the card.

It's the most powerful fix here, and also the most dangerous.

Warning: the clean command wipes the whole disk you select.

If you pick the wrong number, you could erase your PC's own drive. Double-check the size before you type clean.

  1. Open Command Prompt as administrator, like in Method 1.
  2. Type diskpart and press Enter.
  3. Type list disk and press Enter.
diskpart showing the list of disks, with a 14 GB memory card as Disk 1
This screenshot is from my 2015 guide. My 14 GB card was Disk 1. The commands haven't changed.

Find your card by its size. In my case, it was Disk 1.

Now type these commands one by one, pressing Enter after each. Replace 1 with your card's disk number:

select disk 1
clean
create partition primary
format fs=exfat quick label=SDCARD
assign
exit

Here's what each one does:

  • select disk 1 picks your memory card.
  • clean removes all the partitions and formatting from it.
  • create partition primary makes one new partition.
  • format fs=exfat quick formats it as exFAT. For a card of 32 GB or less, use fs=fat32 instead.
  • assign gives it a drive letter, so it shows up in File Explorer again.

You might be wondering what happened to the active command from 2015. You don't need it, because it's only for drives you want to boot a PC from.

How to Fix the "The Media Is Write Protected" Error

Check the lock switch on the card first.

If that's not it, type this right after select disk 1, then carry on:

attributes disk clear readonly

If the card still won't accept changes after that, the card itself may be failing. See the section on replacing it below.

How to Use the Official SD Card Formatter

If you have an SD or microSD card, there's one more tool worth trying.

The SD Association, the group behind the SD card standard, makes a free app called SD Memory Card Formatter for Windows and Mac.

It formats cards the way the SD standard expects, and the SD Association recommends it over the formatting tools built into Windows and macOS.

Like any format, it erases the card.

How to Repair a Memory Card on a Mac

Mac users can do all of this with Disk Utility.

How to Run First Aid (Doesn't Erase Anything)

  1. Open Disk Utility and choose "View" → "Show All Devices".
  2. Select the card in the sidebar.
  3. Click "First Aid", then "Run".

How to Erase and Reformat a Card on a Mac

Warning: this erases everything on the card.

  1. In Disk Utility, select the card itself in the sidebar and click "Erase".
  2. For "Format", choose "MS-DOS (FAT)" for cards of 32 GB or less, or "ExFAT" for bigger ones. Both work with Windows too.
  3. For "Scheme", Apple's guide uses "GUID Partition Map".
  4. Give it a name and click "Erase".

Using the card in a camera or phone? Format it once more inside that device, so it's set up exactly the way the device likes.

When to Replace a Memory Card

Sometimes a card is just dead. It's time to stop trying when:

  • It doesn't show up in Disk Management or Disk Utility on any computer.
  • It's still read-only after all the steps above.
  • It keeps getting corrupted again, even after a full format.
  • It's cracked or bent.

If the files on it are really important, a professional data recovery lab may still be able to get them back. It isn't cheap, so try Windows File Recovery first.

Also Read: How to Move Apps and OBB Files to an SD Card on Android

How to Stop a Memory Card from Getting Corrupted

  • Always eject the card or pendrive safely before pulling it out.
  • Don't remove a card from a phone or camera while it's saving.
  • Buy cards from brands and shops you trust. A suspiciously cheap high-capacity card can be fake.
  • Keep a backup of anything important. A memory card should never be the only copy of your photos.

Final Thoughts

Start with chkdsk, recover your files if you need them, and only then format with Disk Management or diskpart. Most "dead" cards come back to life with one of these methods.

The main caveat is that every formatting method erases the card. If your files are on it, recover them first.

If a card keeps getting corrupted, even after a full format, stop using it and replace it.

FAQs

How do I fix a corrupted SD card without losing my files?

Run chkdsk E: /f in an administrator Command Prompt, replacing E: with your card's drive letter. It repairs file system errors without erasing anything.

Should I format my memory card when it asks to be formatted?

Only after you've recovered anything important. Formatting erases everything on the card, so use Windows File Recovery to copy your files off first.

Should I use FAT32 or exFAT for a memory card?

Use FAT32 for cards of 32 GB or less, and exFAT for anything bigger. Both work with Windows, and Disk Utility on a Mac offers them too.

Is SD Memory Card Formatter better than the built-in formatting tools?

The SD Association recommends its free SD Memory Card Formatter over the formatting tools built into Windows and macOS. It erases the card, so recover your files first.

Still stuck? Tell me through the contact page.

Xaif (Huzaifa Dhapai) started TechVerge in 2015. He's a web developer and long-time Android enthusiast who writes about Android tricks, apps, Windows and the tech he uses every day.

Topics

Comments (1)

Comments are closed. Have a question about this article? Ask through the contact page.