How To Reformat SD Card to use it Normally

When using SD cards in a Raspberry Pi, the software will repartition the card in a way in prevents Windows from reading or formatting it. Here's how to fix that.

By Tim Trott | Raspberry Pi Projects | July 29, 2017

When using tools like Etcher to write disk images to an SD card (or USB thumb/flash drive) they will often re-partition the drive and use Linux file systems. If you want to use these cards again in a camera or on Windows you may notice that the SD card capacity has shrunk down to only a few megabytes, or you can't read the card at all!

Fret not. I'll show you how to restore the SD Card to normal in Windows.

Caution. The process here will erase all data on the drive selected. Make sure you select the right drive and that you are OK to lose all data on the SD card.

First, when you insert the SD card into the computer you will probably get a message saying that you must format the drive before you can use it.

You must format the disk in order to use it
You must format the disk in order to use it

Clicking on "Format disk" will show another popup screen with details on the disk and allow you to start the format process. However, you will notice that the capacity is greatly reduced. This is because the first partition was used by Raspberry Pi as a bootloader. The rest of the data is on another partition which is hidden (for now).

Formatting SD Card and Capacity is Lower than it should be
Formatting SD Card and Capacity is Lower than it should be

Once the format is complete you can see the drive structure in Disk Manager (Start -> Create and Format Hard Disk Partitions)

Window Disk Management Partition View
Window Disk Management Partition View

Notice that the drive has two partitions and unallocated (free) space. We need to delete the partitions and create a new partition equal to the capacity of the drive. Right-click on the partitions for the SD card (NOT the hard drive or any other drives you may have installed!) and select delete.

Window Disk Management Partition View
Window Disk Management Partition View

You will then have a large chunk of unallocated space. Usually (and if you're very lucky) you can right-click this unallocated space and create a new simple partition. If that works for you great, your card is now fixed!

If not, clicking the menu item will do nothing, so carry on with the steps below.

Reformat SD Card in Windows

Open up your command terminal of choice and enter DISKPART and hit enter.

We need to be very careful to select the right disk here, or else you could lose data or wipe Windows from your computer.

Type in LIST DISK and hit enter.

DISKPART List Disks attached to computer
DISKPART List Disks attached to computer

This will show a list of all the physical disks attached. Carefully check which one is the SD card. For me, it is disk 1.

Change the active working drive by typing SELECT DISK 1 taking care to enter the correct drive number from the disk list.

You can then use LIST PARTITION to list the partitions on the disk. If you deleted them in Windows Disk Manager then no partitions will show.

DISKPART - Listing Partitions on Disk
DISKPART - Listing Partitions on Disk

We can now refresh the partition table on the SD card with the CLEAN command.

DISKPART - Clean Disk Partition Tables
DISKPART - Clean Disk Partition Tables

And finally, we can create a new partition by entering CREATE PARTITION PRIMARY.

DISKPART - Create New Primary Partition
DISKPART - Create New Primary Partition

You can now exit the diskpart tool, eject the SD card and re-insert it.

You will again see a message indicating that you need to format the drive before use. Proceed to do so and this time notice that the capacity has been restored.

Formatting SD Card with Correct Capacity Reinstated
Formatting SD Card with Correct Capacity Reinstated

Once the format is complete your SD card has been restored to its original condition and can now be used as normal.

Reformat SD Card in Linux / Mac OS

You can follow a similar process in Linux using FDISK or CFDISK.

In a terminal, start fdisk /dev/sdx where /dev/sdx is your SD card device (may depend on the Linux distro you're using, see below). You can then delete all existing partitions on the device by typing d, and then adding a single new partition & format it. You can also just type n to create a new partition table and start laying everything out.

cfdisk is also another viable tool, which is basically fdisk with a greatly improved user interface. In both cases, once the drive is formatted, you will lastly need to mount it.

If you're unable to determine the proper device, remove the SD card, run fdisk -l, and then re-run it with the SD card inserted. The SD card is just the device that has been added.

Was this article helpful to you?
 

Related ArticlesThese articles may also be of interest to you

CommentsShare your thoughts in the comments below

If you enjoyed reading this article, or it helped you in some way, all I ask in return is you leave a comment below or share this page with your friends. Thank you.

There are no comments yet. Why not get the discussion started?

We respect your privacy, and will not make your email public. Learn how your comment data is processed.