How to repair corrupted sd card using cmd diskpart - 3 ways

Background

Has your SD card been damaged, causing you to lose all your data? Don’t worry! In this guide, you can learn how to repair the corrupted SD card using CMD command prompt tools like chkdsk or Diskpart without losing data.

Scenario: My SD card gets corrupted, how to fix?

"I wanted to format the sd card yesterday, but I don’t know why Windows failed to format the card, and the device became inaccessible, the device showed 0 byte, I know this means the sd card got corrupted. I have important data on the sd card, is there any solution to repair the damaged sd card without data loss?"

How to repair the corrupted sd card without data loss? It is not that hard if you are an advanced user. However, we won't recommend computer starters to repair sd card using cmd since it is a little complicated that can easily get lost or the cmd won't work for you.

Solution 1: Repair corrupted sd card using cmd diskpart

Part 1 - Repair damaged sd card, microsd card using diskpart [3 ways]

CMD command prompt diskpart is a Windows system tool which can perform a lot of operation performance. If your device becomes raw drive, then you can use CMD command prompt diskpart to repair it. You just need to convert the file system from raw to NTFS, FAT32, or other file system. But you need to know there are some risks when you use this system command operation tool.

Attention:

You need to pay attention to the process when you use CMD command prompt, which can make your another hard drive get formatted by mistake.

This process will erase every file on your memory card, you need to recover them at first before using cmd. How? iCare Pro Free is able to help, which is listed at the third part of this article.

Preparations:

  1. Run CMD in your computer by opening Run and type 'cmd/diskpart' to open.
  2. Open your computer and remember which drive letter your memory card has and remember it correctly since it would be used in the cmd.

Repair corrupted sd card with cmd diskpartStart cmd

Note: If you type 'cmd' or 'CMD' in the run box to open, next you will need to type 'diskpart' in the coming up window to start the journey of diskpart.

CMD Way 1 - format * /fs:fat32

Type “format F: /fs:fat32” (F is the drive letter that you need to replace with your own corrupted sd card drive letter that you need to open your computer to check which drive letter does your computer assign it with before all the steps.)

Repair corrupted sd card with cmd diskpartRepair damaged sd card using cmd

CMD Way 2 - List volume, select, format

  1. Step 1 - list volume
  2. Step 2 - select volume 4
  3. Step 3 - format fs=fat32 quick
  4. Step 4 - exit

This way of cmd does not require any drive letter from you that can be selected in the listed volumes

Repair corrupted sd card with cmd diskpartRepair corrupted sd card with cmd diskpart

CMD Way 3 - List disk, clean, create partition primary, format

  1. Step 1 - diskpart
  2. Step 2 - select disk 1 (you need to replace 1 with your own memory card volume number)
  3. Step 3 - clean
  4. Step 4 - create partition primary
  5. Step 5 - format fs=ntfs quick (or you may use 'format fs=fat32 quick')
  6. Step 6 - exit

Repair corrupted sd card with cmd diskpartRepair corrupted sd card with cmd diskpart

After these steps, you can convert your device file system into FAT32, you can also change the FAT32 into NTFS if you want to convert your file system into NTFS.

This operation will format your disk, if you have important data on it, recover them first.

If your SD card becomes inaccessible, you can try CHKDSK to check the disk.

Solution 2 - Repair damaged SD card using CHKDSK

CHKDSK is able to fix errors on digital devices that you may use in the following way.

Preparation: Open your computer 'This PC' and then see what drive letter the computer has labeled your memory card.

  • Firstly, start CMD
  • Secondly, type chkdsk h:/f (you need to replace 'h' with your own memory card drive letter that appears in your computer)

cmd chkdsk to repair sd card

* /f - Fixes errors on the disk.

Different CHKDSK Commands for Repairing SD Cards:

  • chkdsk /f - This command checks the file system and fixes logical file system errors.
    Example: chkdsk E: /f
  • chkdsk /f /r - This command not only fixes file system errors but also locates bad sectors on the SD card and attempts to recover readable data.
    Example: chkdsk E: /f /r
  • chkdsk /f /r /x - This command performs the same functions as /f /r but also forces the volume to dismount before scanning.
    Example: chkdsk E: /f /r /x

In addition to CHKDSK, there are other CMD commands that can help recover a damaged SD card. Below are the common commands:

  • diskpart - This command opens the DiskPart utility, which allows you to manage your disk partitions. This is introudced in the article as the first solution.
    Steps:
    1. Type diskpart and press Enter.
    2. Type list disk to see all the disks connected to your computer.
    3. Type select disk X (replace X with your SD card number).
    4. Type clean to remove all partitions and data on the SD card.
    5. Type create partition primary to create a new primary partition.
    6. Type format fs=fat32 quick to format the SD card to FAT32.
    7. Type exit to close DiskPart.
  • sfc /scannow - This command scans and repairs corrupted system files that might be affecting your SD card.
    Steps:
    1. Open CMD as an administrator.
    2. Type sfc /scannow and press Enter.
    3. Wait for the scan to complete and follow any prompts.

Part 3 - Using CMD Attributes to Repair a Damaged SD Card

Follow these steps to manage attributes on your SD card using CMD commands. Ensure you replace "X" with the correct drive letter for your SD card. Be cautious, as changing attributes can affect file visibility and access.

  • Open Command Prompt:
    cmd

    Launch Command Prompt by searching for "cmd" in the Start menu and selecting it.

  • Set the SD card to read-only, hidden, and system attributes:
    attrib X: +r +h +s

    This command sets the SD card to read-only, hidden, and system attributes. Replace "X:" with your SD card’s drive letter. This can help protect the SD card from accidental modifications.

  • Remove read-only, hidden, and system attributes (if needed):
    attrib X: -r -h -s

    To reverse the previous attributes and make the SD card writable, visible, and not a system file, use this command. Replace "X:" with your SD card’s drive letter.

  • Apply attributes to all files and directories on the SD card:
    attrib +r +h +s X:\* /S

    This command applies the read-only, hidden, and system attributes to all files and subdirectories on the SD card. Replace "X:" with your SD card’s drive letter.

  • Remove attributes from all files and directories on the SD card (if needed):
    attrib -r -h -s X:\* /S

    This command removes the read-only, hidden, and system attributes from all files and subdirectories on the SD card. Replace "X:" with your SD card’s drive letter.

Replace "X" with the appropriate disk number for your SD card. Use these commands with caution, especially the format command, as it will erase the data on your card.

How to Recover Data from a Corrupted SD Card with iCare Pro

Before using CMD Diskpart to repair the corrupted SD card, it’s recommended to recover your data with a professional recovery tool like iCare Data Recovery Pro. This program is 100% safe and can handle various data loss scenarios. It is compatible with Windows 11/10/8/7/XP/Vista.

Free Download

Follow these simple steps to recover your data:

Step 1: Download and install iCare Data Recovery on your computer.

Step 2: Run the program and select “Deep Scan Recovery”.

Recover corrupted SD card data with iCare Data Recovery ProRecover corrupted SD card data with iCare Data Recovery Pro

Step 3: After scanning, preview the found data, select what you need, and save it to another drive.

Recover corrupted SD card data with iCare Data Recovery ProRecover corrupted SD card data with iCare Data Recovery Pro

Free Download

Be sure to save the recovered data to a different location to avoid overwriting the SD card. If you’ve already formatted the SD card, iCare Data Recovery Pro can still help recover the data. However, it’s best to recover your data before using any CMD commands.

Recommend: 8 free SD card repair tools instead of using Command Prompt to repair damaged memory cards.

Last updated on July 18, 2024

Related Articles