How to fix repair a corrupted USB flash drive and SD card with CMD?

USB flash drives and SD cards are convenient for storing and transferring files. However, they can become corrupted over time due to various issues, making the data inaccessible. Corruption usually occurs when the file system or data structure on the drive becomes damaged.

Common causes include improper ejection, virus infection, power outages, file system errors, bad sectors, and physical damage. When corruption happens, special utilities like the command prompt (CMD) may be required to fix the drive and recover data.

This guide provides solutions for repairing a corrupted USB or SD card using CMD commands. It covers diagnosing the problem, fixing drive errors, resetting the file system, and advanced troubleshooting. With the right steps, you can often repair the corruption and regain access to your valuable files and data again.

Symptoms of a Corrupted Drive

There are a few common symptoms that indicate your USB flash drive or SD card may be corrupted:

Error messages when trying to access the drive – You may get errors like “Drive is not accessible” or “You need to format the disk” when trying to open files on the corrupted drive (Source).

Drive not being recognized – Your computer may fail to detect the USB or SD card when you plug it in, or the drive may not show up in File Explorer (Source).

Data inaccessibility – You may be unable to open, copy, or transfer files and folders on the corrupted drive. Existing data may appear missing or inaccessible (Source).

Causes of Corruption

There are several potential causes of a corrupted USB flash drive or SD card:

Improper ejection: Removing the flash drive or memory card before properly ejecting can lead to corruption. The data may not have finished writing before being disconnected, leaving the files in an incomplete or corrupt state. Always safely eject external drives before disconnecting.

Physical damage: Dropping, bending, or otherwise damaging the physical drive can destroy components and make data inaccessible. Check for any cracks, dents or other visible damage. (Source)

Malware/viruses: Malicious software can infect drives and modify or corrupt files. Scan devices with anti-virus software regularly to detect and remove any malware.

Power outages: An unexpected loss of power while writing data can lead to file system corruption or bad sectors. Use a surge protector and properly shut down devices before power failures.

Back Up Your Data

Backing up your data is a crucial first step before attempting to fix a corrupted USB flash drive or SD card. According to The 2022 Backup Survey, 54% of people have experienced data loss, often because they failed to maintain backups. Backing up ensures you have copies of your important files in case they become inaccessible or corrupted.

To back up a USB or SD card, first connect it to your computer. Then locate the drive in File Explorer or Finder and copy all the files and folders you need to save. The best destinations for backups are external drives, cloud storage services like Google Drive or Dropbox, or networked storage locations. Store your backed up files in more than one location to be extra cautious.

Back up the entire contents of the drive if possible. If needed, prioritize backing up your most important irreplaceable files like documents, photos, videos, etc. Verify the copied files open properly from the backup location before proceeding.

Check the Drive

One of the first things to try when troubleshooting a corrupted USB drive is to scan it for errors using built-in Windows tools. The CHKDSK and SFC commands can help detect and repair logical file system errors.1

To run CHKDSK, open the Command Prompt as Administrator and type chkdsk X: /f where X is the letter of your USB drive. This scans the drive and fixes any file system errors it finds. You can also add /r to locate bad sectors and recover readable data.2

The SFC or System File Checker can scan for and replace corrupted system files. Type sfc /scannow in an Admin Command Prompt to run it. This helps fix errors related to Windows files.

Running these built-in utilities is a good first step before trying more advanced drive repair methods. They can automatically fix many logical errors that may be causing corruption.

Format the Drive

Formatting the USB drive or SD card is often the best way to fix corruption and get it working again. Formatting completely erases all data on the drive and recreates the file system. This clears out any corrupted data or directory issues. Formatting with the command line is simple and can help fix even severe corruption that prevents the drive from appearing properly in File Explorer.

To format a drive using CMD:

  1. Connect the corrupted USB or SD card to your computer.
  2. Open the Command Prompt as administrator.
  3. Type diskpart and press Enter.
  4. Type list disk to display all connected drives and their disk number.
  5. Select the corrupted disk by typing select disk X (replace X with the disk number).
  6. Type clean to completely erase and reformat the drive.
  7. Type create partition primary to create a new primary partition.
  8. Type format fs=fat32 quick to format the partition with FAT32.
  9. Type assign to assign a drive letter.
  10. Type exit to close diskpart.

The drive will now be emptied, reformatted, and ready to use again. Be sure to back up any important data first, as formatting erases everything. This should resolve many corruption issues, especially if the drive was not even being detected properly before formatting.

Clean with DISKPART

DISKPART is a command-line utility built into Windows that allows you to clean and format drives. To use DISKPART to clean your corrupted USB or SD card:

1. Open the Command Prompt as an administrator. Type “cmd” in the Windows search box, right-click on Command Prompt, and select “Run as administrator”.

2. Type “diskpart” and press Enter to launch the DISKPART utility.

3. Type “list disk” to display all the connected disks and drives. Identify the corrupted USB or SD card drive letter.

4. Type “select disk x” where x is the drive letter of the corrupted drive. This will select the target drive.

5. Type “clean” and press Enter. This will completely wipe and erase all data on the drive.

6. Type “create partition primary” to create a new primary partition on the drive.

7. Type “format fs=fat32 quick” to quickly format the drive to FAT32 file system.

8. Type “exit” to close DISKPART.

After using the clean command in DISKPART, the USB or SD card should be wiped clean of corruption and reformatted for use again1.

Reset the Drive

If corruption persists after formatting, you may need to reset the USB drive’s hardware and reinstall the drivers. This refreshes the connection between the drive and your computer.

To reset the USB hardware in Windows 10 and 11:

  1. Open Device Manager.
  2. Expand the Universal Serial Bus controllers section.
  3. Right click on the USB device and select Uninstall device.
  4. Check the box to delete the driver software too.
  5. Restart your computer and Windows will reinstall the USB controller drivers.

You can also use the Device Manager to update your USB drivers. Simply right click on the device, select Update driver, and follow the on-screen instructions to get the latest version. Keeping your drivers updated helps avoid corruption issues.

Resetting the hardware and reinstalling drivers essentially gives your USB drive a fresh start on that computer. This simple fix resolves many mysterious corruption problems that other methods cannot.

Advanced Fixes

If the basic troubleshooting steps don’t resolve your USB drive issues, you may need to try some advanced fixes. Here are some options:


TestDisk is a powerful free USB drive repair tool specifically tailored for partition repair and reconstruction. Its remarkable capabilities include fixing partition table and boot sectors, recovering deleted partitions, and rebuilding FAT32 boot sectors. TestDisk can be an excellent solution when dealing with severely damaged or unresponsive USB drives.

Third Party Tools

There are many third party USB repair tools that offer advanced capabilities beyond the built-in Windows options. Some top USB repair software choices include:

  • Disk Drill – praised as one of the best data recovery apps for USB drives. It repairs corrupted drives and recovers lost files.
  • Rufus – creates bootable USBs and can be used to fix drive errors.
  • Etcher – burns drive images to USBs and SD cards with advanced validation checks.

Low Level Formatting

If your USB drive is still not working after trying the above options, low level formatting may be necessary. This completely erases and reformats the drive at a low disk level. However, it will result in complete data loss. Some tools that can low level format USB drives include HDD Low Level Format Tool and Low Level Format Tool.

Prevention Tips

You can take some steps to help prevent your USB flash drive or SD card from becoming corrupted in the first place:

Properly eject the drive – Always use the “Safely Remove Hardware” option in Windows or the “Eject” command in Mac OS before unplugging your flash drive. Improperly ejecting the drive while files are still being written can cause corruption. [1]

Handle drives carefully – Avoid exposing flash drives to extreme heat, cold, or moisture. Don’t bend or drop drives. Store them in a protective case when not in use. [2]

Scan for malware – Run an antivirus scan on your flash drives periodically to check for malware or viruses, which can sometimes corrupt data. [3]