If you've used an SD card for more advanced purposes than simply storing digital photos (e.g. running a mobile or micro OS), you'll find it requires a little more finesse than simply formatting the card to reclaim all the space. Read on as we show you how.

Dear How-To Geek,

I followed along with one of your great Raspberry Pi tutorials a few months ago. Just recently I upgraded to a bigger SD card for the Pi and pulled the old one to use for another project. When I went to reformat the card only 64MB out of the original capacity was available and even when I went into Disk Management in Windows the best I could do is dump the contents of the inaccessible (and presumably Linux-filled) partition. This left me with a tiny Windows accessible partition and a big phantom partition I can't do anything with.

I'm sure there's a simple fix but I'm not even sure if I did a good job describing my problem (so as you an imagine I'm at a loss for what to search for in Google to get to the bottom of things!) Help!

Sincerely,

Suffering from Stunted SD Card

Don't worry Suffering, we grabbed a card we'd previously used for a Pi project just to recreate your situation and show you  how to get the full capacity of your card back. The heart of the problem is the partition changes the SD card undergoes during the initial PI setup: 64MB of the card is reserved as a Windows-accessible FAT32 partition which hosts configuration files and other small files that benefit from cross-OS FAT32-based accessibility (so you can easily pop the SD card in a modern PC and tweak those configuration files) and the rest is formatted for use by Raspbian, which is a Debian-derived version of Linux. As a result, the majority of the card becomes somewhat of a black hole to Windows.

That said, it's easy to repair when you have the right tool at your fingertips. First, let's take a peek at what the SD card looks like if you attempt to reclaim the space using Disk Manager as you did:

You can format the tiny 64M FAT32 partition, but the remainder of the SD card remains "Unallocated" after you dump the existing (and inaccessible) Linux partition. No amount of pushing or shoving in the Disk Manager application is going to fix this problem. Instead, we're going to turn to the simple and effective DISKPART tool.

Open up the Start Menu and type "diskpart" in the run box. Press enter. You'll be prompted by the Windows UAC to authorize admin access to the DISKPART tool.

A command-prompt-like window will open up, only the prompt will say "DISKPART". At that prompt, type "list disk".

In the list output on our machine you can see the computer's hard drive (119GB) and the removable SD card (14GB). It is absolutely critical you note the proper disk number. DISKPART commands are immediate and without any warning. If you type in the wrong disk number, you're going to have a really bad time.

After identifying your SD card's disk number, enter the following command "select disk #" where # is the disk number of your SD card.

Whatever commands you execute after this point will only make changes to the selected disk; now would be a good time to double check you've selected the right disk just to be extra safe.

Next, now enter the command "clean"

The clean command zeroes out the sectors of the disk that contain the partition data. If you wished to zero out all data on the SD card you could use "clean all" instead, but unless you have a pressing privacy/security reason for overwriting the the entire SD card with zeros, it's unwise to waste the read/write cycles of the flash media.

After cleaning the disk, enter the following command "create partition primary"

The command, as the syntax implies, creates a new partition on the disk and sets it to primary. After creating the primary partition, the entire storage capacity of the SD card should be available to Windows. If we peek back into Disk Manager, we no longer see a tiny partition with a huge hunk of unallocated space, but a large partition ready to be formatted:

That's all there is to it! A little DISKPART wizardy and the SD card is factory fresh again.