How to remove write protection from SD card using command prompt?

Having a write protected SD card can be very frustrating, as it prevents you from saving any new data to the card. Thankfully, there are a few methods you can use to remove write protection from an SD card when working in the Windows command prompt. In this comprehensive guide, we will walk through the steps to remove write protection from an SD card using the command prompt in Windows.

What Causes an SD Card to Become Write Protected?

There are a few potential causes of an SD card becoming write protected:

  • The lock switch on the side of the SD card is slid to the “lock” position. This physically blocks new data from being written to the card.
  • The card has been formatted with special software that sets the write protection flag in the card’s controller chip.
  • There is a problem with the SD card controller chip itself that has enabled write protection.
  • The disk has been marked as read-only in Windows due to a corruption issue.

The most common reasons are either the physical lock switch being toggled on, or the disk having been formatted with software that sets the write protection flag. Thankfully, we can use the command prompt to check the status of the disk and remove the write protection if needed.

Check the Write Protection Status of an SD Card

The first step is to insert the SD card into your Windows PC and determine if write protection is enabled. To do this:

  1. Open the command prompt window. You can do this by pressing Windows + R and typing “cmd”, then hitting Enter.
  2. Type the following command and hit Enter:

    diskpart

  3. This will open the DiskPart utility for managing disks. Next, type the following and hit Enter:

    list disk

  4. This will show a list of all disks connected to your PC. Look for the disk number of your SD card in the list.
  5. Type the following command using your SD card’s disk number, and hit Enter:

    select disk x (where x is your disk number)

  6. Finally, type this command and hit Enter:

    attributes disk

This will display the properties of your selected disk. Look at the “Read-only” status. If it says “Yes”, then write protection is currently enabled on your SD card.

Use DiskPart to Remove SD Card Write Protection

If you’ve confirmed that write protection is enabled on your SD card, you can use the DiskPart utility to remove it. Here are the steps:

  1. Open the command prompt and type diskpart
  2. Type list disk and note your SD card’s disk number
  3. Type select disk x (replace x with your disk number)
  4. Type attributes disk clear readonly

This will clear the read-only attribute on your SD card, disabling write protection. You can now type attributes disk again to confirm that “Read-only” now says “No”.

Using Diskpart to Clean and Create New Partition

In some cases, simply clearing the read-only flag may not be enough to fully remove write protection from the card. If that happens, you may need to completely reformat and repartition the SD card.

Here are the steps to use DiskPart to clean and recreate the partition on a write protected SD card:

  1. Open the command prompt and run diskpart
  2. Type list disk and note the disk number of your SD card
  3. Type select disk x (replace x with disk number)
  4. Type clean to completely erase all existing partitions
  5. Type create partition primary to create a new primary partition
  6. Type format fs=fat32 quick to format the partition with FAT32
  7. Type active to mark the partition as active
  8. Type assign to assign a drive letter to the disk

After following these steps, your SD card will have a completely clean partition table and file system, which should remove any trace of write protection.

Using Disk Management to Remove Write Protection

You can also use the Disk Management utility in Windows to remove write protection from an SD card. Here is how:

  1. Press Windows + R to open the Run dialog
  2. Type diskmgmt.msc and click OK to launch Disk Management
  3. Right-click on your SD card and select “Properties”
  4. Go to the “Hardware” tab and click the Change Settings button
  5. Uncheck the checkbox next to “Read-only”
  6. Click OK to save the changes

This will update the registry settings for the SD card and remove the read-only attribute. The disk properties in DiskPart should now show the card as read/write enabled.

Using the Command Prompt to Remove Physical Write Protection

If your SD card has a physical write protect switch on the side, you’ll need to make sure it is slid to the unlocked position. With the card inserted in your Windows PC:

  1. Open the command prompt
  2. Type diskpart
  3. Type list disk to identify your SD card disk number
  4. Type select disk x (replace x with your disk number)
  5. Type attributes disk and verify “Read-only” says “No”

If the SD card properties show no read-only attribute, then check the physical lock switch on the card itself. Slide it to the unlocked position and the card should now allow writing data.

Formatting an SD Card to Remove Write Protection

If you are still unable to write to the SD card even after removing attributes and physical locks, you may need to fully format it. Here are the steps:

  1. Open the command prompt as admin
  2. Type diskpart
  3. Type list disk and identify your SD card disk number
  4. Type select disk x (replace x with disk number)
  5. Type clean to delete all existing partitions
  6. Type create partition primary to create a new primary partition
  7. Type format fs=fat32 quick to quickly format FAT32
  8. Type active to make partition active
  9. Type assign to assign next available drive letter

This will completely reformat your SD card and overwrite any previous write protection. Just be aware this will erase all existing data on the card.

Using Third-Party Tools to Remove Write Protection

There are also several third party tools available that are designed to remove write protection from SD cards and other media.

Some popular options include:

  • HDD LLF Low Level Format Tool – Free low level disk formatting utility that bypasses normal operating system write protection.
  • HP USB Disk Storage Format Tool – Tool from HP that can format USB and SD cards with write protection removed.
  • RidDisk Write Protection – Shareware app designed specifically for removing write protection attributes.

To use these, first backup any important data from your SD card. Then download and install the tool. Follow the instructions to connect your SD card and use the software interface to format/clear write protection attributes.

Troubleshooting Tips for Write Protected SD Cards

If you are still unable to remove write protection from your SD card after trying all of the above methods, here are some troubleshooting tips:

  • Try formatting the SD card using the official SD Association formatting tool for best results.
  • Check if your SD card adapter/reader has its own physical write protect switch enabled.
  • Try connecting the SD card to a different computer system and see if the issue persists.
  • Inspect the SD card for any physical damage or corrosion on the contacts.
  • As a last resort, you may need to purchase a new SD card if the controller chip itself has permanently failed.

Hopefully with one of the formatting methods described here, you should be able to successfully remove software-based write protection on your SD card. But for damaged or defective cards, replacement may be necessary.

Using Windows to Remove Write Protection from USB Flash Drive

The process for removing write protection from a USB flash drive is very similar to the steps for an SD card.

Here is an overview of how to make a write protected USB drive writable again in Windows:

  1. Open Diskpart from admin command prompt
  2. Type list disk to identify the disk number of your USB drive
  3. Type select disk x (replace x with your disk number)
  4. Type attributes disk clear readonly to remove read-only attribute
  5. Alternatively, use clean and create partition to reformat
  6. Also toggle any physical write protect switch on the USB drive body
  7. Use Disk Management to change the drive hardware settings as needed

The same troubleshooting tips apply as well. Reformatting and repartitioning your USB drive can force it to become writable again in cases where simply clearing attributes does not work.

Conclusion

Write protected SD cards and USB drives can certainly be annoying. But in most cases, you can use the command line tools built into Windows to remove write protection attributes and get your removable media working properly again.

The key tools for removing software write protection are Diskpart from the command prompt and Disk Management in Windows. Reformatting or repartitioning drives is often necessary for stubborn cases of write protected disks.

Just remember to always backup your SD card or USB drive before making any major changes to the filesystem. And if all else fails, damaged media may simply need to be replaced.

We hope this guide has provided you with a complete overview of how to remove write protection from SD cards and USB drives in Windows. The command prompt solutions should help get your removable storage functioning normally again.