Format SD Card with Command Prompt (CMD)/Diskpart: A Comprehensive Guide

Steven
Written byStevenUpdated on Feb 19, 2025
Gerhard Chou
Approved byGerhard Chou

Table of Contents

PAGE CONTENT:

When it comes to managing storage devices, formatting is a fundamental task that can solve a variety of issues. Whether you're looking to erase data, fix errors, or prepare a device for a new operating system, knowing how to format an SD card using CMD (Command Prompt) can be an invaluable skill. Unlike graphical user interface (GUI) methods, CMD offers a direct and often quicker way to handle such tasks. In this article, we will walk you through the process of formatting an SD card using CMD, discuss the prerequisites, potential issues, and provide a thorough understanding of the process.

format an SD card using CMD

Before Formatting SD Card with CMD / diskpart

Understand the Basics:

Before diving into the technicalities, it's essential to understand why and when you might need to format your SD card. Over time, SD cards may become corrupted or might not be formatted correctly to work with certain devices. Other reasons for formatting could include changing the file system, erasing old files, or preparing the SD card for a fresh start.

While most operating systems offer GUI-based methods for formatting SD cards, using CMD allows more control over the formatting process. CMD also comes in handy when the SD card is not recognized by the operating system through conventional means. By learning how to use CMD for formatting, you gain access to a powerful tool that can help resolve issues that GUI options might not address.

 
Best 5 Methods to Format Hard Drive on Windows

Best 5 Methods to Format Hard Drive on Windows

Here are 5 reliable ways to format SD card, USB flash drive, HDD, SSD on Windows 11/10/8/7, etc.

Prerequisites:

Before proceeding with formatting an SD card, it's important to ensure that you're prepared for the task. Make a backup of whatever you wish to save on the SD card because formatting will remove all of the data.

Here are a few points to consider:

  1. Backup Your Data: Formatting an SD card will erase all the files stored on it. Make sure to back up your important photos, videos, documents, and other files to your computer or a cloud service. Once the card is formatted, recovering the data without backup becomes significantly harder.
  2. Choose the Right File System: When formatting an SD card, you'll need to decide which file system to use. Common options include FAT32, exFAT, and NTFS. Each file system has its advantages, and the choice largely depends on the type of device the SD card will be used in. For example, FAT32 is widely compatible but has file size limitations, while exFAT is ideal for larger files and more modern devices.
  3. Check for Errors: If you're formatting an SD card because of errors (e.g., "SD card not recognized" or "corrupted SD card"), ensure that the card is properly connected to your computer. You may also want to run a check for physical damage, as this could affect the formatting process.
  4. Administrator Privileges: Using Command Prompt/diskpart to format an SD card requires administrator access. Ensure you have the necessary permissions to run system commands on your computer.

Step-by-Step Guide to Format SD Card Using CMD [8 Steps]

Now that you're ready, let's dive into the process of formatting an SD card using CMD. The procedure involves using the diskpart utility, which allows you to manage disks, partitions, and volumes. Here's how to do it:

Step 1: Launch the Command Prompt in Administrator mode

To start, you need to open Command Prompt with administrator privileges:

For Windows 10/11: Type cmd in the search bar, right-click on Command Prompt, and select Run as administrator.

format an SD card using CMD

This step ensures that you have the necessary permissions to make changes to system-level components such as disks and storage devices.

Step 2: Identify the SD Card

Once the Command Prompt window is open, you need to identify the correct disk that corresponds to your SD card. Be careful at this stage, as selecting the wrong disk could result in the loss of important data.

Step 1. Type diskpart and press Enter to launch the DiskPart utility.

format an SD card using CMD

Step 2. Type list disk and press Enter. This command lists all the connected drives to your computer, including your SD card.

  • In the list of disks, locate your SD card by its size. If you're unsure, compare the disk sizes shown to the actual capacity of your SD card. For example, if your SD card is 32 GB, find the disk with a size of approximately 32 GB.
  • The disks will be labeled as "Disk 0," "Disk 1," etc. Identify which one corresponds to your SD card.

format an SD card using CMD

Step 3: Select the SD Card

After identifying the SD card, you need to select it for formatting. This is done by entering the following command:

Type select disk X (where X is the number of your SD card) and press Enter.

format an SD card using CMD

For example, if your SD card is listed as Disk 1, you would type select disk 1.

Step 4: Clean the SD Card

Now that the SD card is selected, it's time to clean it. Cleaning the disk removes all partitions and data on the SD card, essentially resetting it.

Type clean and press Enter. This command will erase everything on the SD card, so be sure that you've backed up any necessary files.

format an SD card using CMD

Step 5: Create a New Partition

Next, you'll need to create a new partition on the SD card. This step is essential for making the SD card usable again.

Type create partition primary and press Enter. This will create a primary partition on the SD card, ready for formatting.

format an SD card using CMD

Step 6: Format the SD Card

Now that the SD card has a partition, it's time to format it. You’ll also need to choose the appropriate file system for your needs. The two most common options are FAT32 and exFAT.

To format the SD card with the exFAT file system, type format fs=exfat and press Enter.

format an SD card using CMD

If you need to format the SD card with FAT32 (ideal for devices that don't support exFAT), type: format fs=fat32 and press Enter.

The formatting process will take some time, depending on the size of your SD card. Once it's completed, you’ll see a message saying the format was successful.

Step 7: Assign a Drive Letter

After formatting, you need to assign a drive letter to the SD card so that it can be accessed through your file explorer.

Type assign and press Enter. This command will assign the next available drive letter to your SD card.

Step 8: Exit DiskPart

After completing the above steps, exit the DiskPart utility:

Type exit and press Enter. You can now close the Command Prompt window.

format an SD card using CMD

Your SD card is now formatted and ready to use!

Fix Issues When Formatting SD Card Using CMD

While formatting an SD card using CMD is a relatively straightforward process, you may encounter some issues. Here are a few common problems and their solutions:

  1. Access Denied Error: This error usually occurs if you don't have the necessary administrator privileges. Make sure to run CMD as an administrator by right-clicking on it and selecting Run as Administrator.
  2. The SD Card Is Not Recognized: If your SD card isn't showing up when you run the list disk command, it might be due to a physical connection issue. Try removing the card and reinserting it into the reader. If that doesn't work, try using a different card reader or USB port. If the card is still not recognized, it might be damaged.
  3. The SD Card Is Write-Protected: Some SD cards have a physical write protection switch. Ensure that the switch on the side of the SD card is in the "unlocked" position before attempting to format it.
  4. Formatting Takes Too Long: If the formatting process takes longer than expected, it could indicate an issue with the SD card, such as physical damage or corruption. In this case, you might need specialized software to recover or repair the SD card.

Recover Lost Data from the SD Card with Is Formatted by Command Prompt/Diskpart

The data is not lost for good even the SD card has been formatted. With data recovery program, you can easily unformat the SD card and get all erased/lost files back.

Step 1. Download and install Donemax Data Recovery on your computer and insert the SD card into the computer.

Step 2. Open Donemax Data Recovery, select the SD card, click on Scan button.

Select the Drive

Step 3. Donemax Data Recovery will deeply scan the SD card and find all deleted/formatted/lost files such as images, videos.

Scan the Drive

Step 4. Once the scan is completed, you can preview all recoverable files. Then select the wanted ones, click on Recover button to save them.

Preview and Recover the Files

Conclusion

Formatting an SD card using CMD is a powerful and effective method for addressing a variety of issues, such as corrupted files or the need to change the file system. By adhering to the steps outlined in this guide, you can easily format your SD card without relying on GUI-based methods, which may not always be available or functional. While the process may seem daunting at first, it offers a greater level of control and flexibility over your storage devices.

Remember to back up any important data before proceeding, as formatting erases everything on the card. Additionally, take your time when selecting the correct disk to avoid accidental data loss. With a little practice, using CMD for SD card formatting can become a useful skill in your tech toolbox.

If you want to recover lost images/videos from a formatted SD card, just try data recovery program - such as Donemax Data Recovery.

logo stage

Donemax Data Recovery for Mac

Donemax Data Recovery for Mac is one of the best Mac data recovery software. It is easy-to-use and can help in recovering deleted, formatted, inaccessible or lost data from Mac HDD/SSD, external disk, USB drive, SD card, camera or other storage devices.

Steven
Contributing Writer

Steven

Steven has been a senior writer & editor of Donemax software since 2020. He's a super nerd and can't imagine the life without a computer. Over 6 years of experience of writing technical solutions and software tesing, he is passionate about providing solutions and tips for Windows and Mac users.

Gerhard Chou
Editor in chief

Gerhard Chou

In order to effectively solve the problems for our customers, every article and troubleshooting solution published on our website has been strictly tested and practiced. Our editors love researching and using computers and testing software, and are willing to help computer users with their problems