How to clean sd card using diskpart​?

Cleaning an SD card can become a necessary task when you’re preparing it for use in a different device, clearing out data to speed up performance, or resolving issues such as corrupted files or faulty partitions. One of the most effective tools for cleaning an SD card on Windows is Diskpart, a built-in command-line utility that allows users to manage disks, partitions, and volumes.

What is Diskpart?

Diskpart is a command-line tool available on Microsoft Windows that helps users manage storage devices such as hard drives, USB drives, and SD cards. It allows you to format disks, delete partitions, assign drive letters, and more. Diskpart can be especially useful when other standard methods of cleaning or formatting an SD card fail.

Cleaning an SD card involves removing any data stored on it, which can be done through a few simple steps. However, it’s important to remember that cleaning will permanently delete the data. Always make sure to back up any important files before proceeding.

Preparing for the Task

Before using Diskpart to clean your SD card, ensure the following:

Backup Data: Cleaning your SD card will erase all the data on it, so it’s essential to back up any files you want to keep. You can do this by copying the files from the SD card to your computer or to a cloud storage service.

SD Card Reader: If you’re using an SD card, make sure you have a functioning SD card reader that’s compatible with your computer.

Admin Privileges: Diskpart requires administrative rights to run. Make sure you are logged in as an administrator on your Windows computer.

Ensure Correct Disk Identification: Mistakenly selecting the wrong disk in Diskpart could lead to the loss of valuable data from other drives. Be sure you’re selecting the correct SD card.

Step-by-Step Process for Cleaning an SD Card with Diskpart

Step 1: Open Command Prompt as Administrator

Press the Windows key or click on the Start menu.

Type cmd or Command Prompt in the search bar.

Right-click on Command Prompt from the search results.

Select Run as administrator. This will open the Command Prompt window with administrative privileges.

Step 2: Launch Diskpart Utility

In the Command Prompt window, type the following command:

diskpart

Press Enter to launch the Diskpart utility. You’ll now be in the Diskpart environment, ready to manage your disks.

Step 3: List Available Disks

To identify your SD card, you need to view all available disks on your system. Use the following command:

Each disk is numbered (Disk 0. Disk 1. etc.), and you will need to identify your SD card based on its size. Typically, SD cards are smaller in size (usually 16GB, 32GB, or 64GB), so find the one that matches the storage capacity of your SD card.

Step 4: Select the SD Card

Once you’ve identified the correct disk number for your SD card, use the following command to select it:

bash

select disk 1

(Replace “1” with the number corresponding to your SD card from the previous step.)

You’ll see a confirmation message that indicates which disk has been selected:

csharp

Disk 1 is now the selected disk.

Step 5: Clean the SD Card

Now that the SD card is selected, you can use the clean command to erase all data and partitions from it. This command will remove everything, including files, folders, and the partition table, essentially making the SD card appear as if it were brand new.

To clean the SD card, type the following command:

clean

Press Enter. Diskpart will begin the process of cleaning the SD card. The process usually takes a few moments, depending on the size of the SD card and the data on it. You’ll receive a confirmation once the operation is complete:

DiskPart succeeded in cleaning the disk.

At this point, your SD card has been completely wiped of all data and partitions. The SD card is now unallocated and empty.

Step 6: Create a New Partition

Once the SD card is cleaned, you’ll need to create a new partition in order to use the SD card again. Use the following steps:

Type the following command to create a primary partition:

sql

create partition primary

You’ll receive a message indicating that the partition was successfully created:

DiskPart successfully created the specified partition.

Step 7: Format the SD Card

After creating the partition, you must format the SD card so it can be used for storing data again. To format it, use the following command:

lua

format fs=exfat quick

The fs=exfat part of the command specifies the file system. You can also use fs=fat32 if your SD card is 32GB or less.

The quick option ensures a quick format, which is typically sufficient and much faster than a full format.

You’ll receive a confirmation once the formatting process is complete:

DiskPart successfully formatted the volume.

Step 8: Assign a Drive Letter

After formatting the SD card, you need to assign it a drive letter so that your computer can recognize and access it. To do this, type the following command:

mathematica

assign letter=E

(Replace “E” with the letter you want to assign to your SD card.)

You’ll see a confirmation message:

DiskPart successfully assigned the drive letter.

Step 9: Exit Diskpart

After the SD card is cleaned, partitioned, formatted, and assigned a drive letter, you can exit Diskpart. To do so, simply type:

bash

exit

Press Enter to close Diskpart and return to the regular Command Prompt window.

Step 10: Verify the SD Card

To ensure the SD card has been properly cleaned and is ready to use, open File Explorer and check for the SD card. It should appear as a new device with the assigned drive letter. You can now begin transferring files to it as needed.

Troubleshooting Common Issues

While using Diskpart to clean an SD card is usually straightforward, you may encounter a few issues along the way. Here are some common problems and solutions:

Issue 1: “Access Denied” Error

If you receive an “Access Denied” error while using Diskpart, it may be due to insufficient administrative privileges. Ensure that you have launched the Command Prompt as an administrator (Step 1).

Issue 2: SD Card Not Detected

If your SD card does not appear in the list disk command, try the following:

Ensure the SD card is properly connected via a working card reader.

Restart your computer and reconnect the SD card.

Try using a different USB port or card reader.

Check if the SD card is locked with a physical write protection switch.

Issue 3: Diskpart Cannot Clean the SD Card

Sometimes, Diskpart may fail to clean the SD card due to issues like physical damage, corruption, or write protection. In such cases, try the following:

Make sure the SD card is not write-protected.

Use third-party tools to format the SD card (e.g., SD Formatter).

If the card is physically damaged, it may be beyond repair.

Issue 4: “The Disk Is Write-Protected” Error

If you see a message indicating that the disk is write-protected, you’ll need to disable write protection before proceeding. Some SD cards have a physical write-protection switch, typically located on the side of the card. Make sure it is in the unlocked position.

If the SD card doesn’t have a physical switch or the switch isn’t working, you can attempt to remove write protection using Diskpart by running the following command before cleaning:

arduino

attributes disk clear readonly

Cleaning an SD card using Diskpart is a powerful and efficient way to erase all data and restore the SD card to its original state. The process involves opening Diskpart, selecting the SD card, cleaning it, and reformatting it for use. Always ensure that you have backed up any important data before starting, as this process will erase everything on the card.

Diskpart is especially useful when other methods, such as through File Explorer or standard formatting tools, fail to work. Whether you need to troubleshoot an SD card, prepare it for use in another device, or resolve formatting issues, Diskpart offers a simple and effective solution.

About us and this blog

Panda Assistant is built on the latest data recovery algorithms, ensuring that no file is too damaged, too lost, or too corrupted to be recovered.

Request a free quote

We believe that data recovery shouldn’t be a daunting task. That’s why we’ve designed Panda Assistant to be as easy to use as it is powerful. With a few clicks, you can initiate a scan, preview recoverable files, and restore your data all within a matter of minutes.

Subscribe to our newsletter!

More from our blog

See all posts