Introduction: Repartition SD Card (Windows)

About: I'm a software engineer living in Minneapolis, MN.

While tinkering with my new Raspberry Pi, I put the system in a bad place and it was clear that starting over was easiest. When Raspberry Pi images are installed on a microSD card, the card is divided into multiple partitions. To install Raspbian again, the microSD card needs to have one large partition.

Repartitioning disks is easy with the Windows Disk Management tool, but it doesn't always play nice with removable disks like flash drives and SD cards.

DiskPart is a powerful tool included with Windows. It is fairly easy to use and is able to list, create, and delete partitions. More information on DiskPart: https://technet.microsoft.com/en-us/library/bb4908...

Warnings:

- Be careful. Mistakes with DiskPart can seriously mess up your system.

- Back up any data. Everything on the SD card will be deleted.

Step 1: Open DiskPart

Search for DiskPart by hitting the Windows key and typing "diskpart". The tool will not show up until you have completely typed it out.

Right-click the tool and click "Run as administrator". This will open the DiskPart tool. You will see a command line interface like the picture above.

Step 2: Select Disk to Partition

Selecting the wrong disk could create a very unfortunate experience. Take extra precaution with this step. Make sure any data you wanted on this disk has been backed up.

I recommend disconnecting any extra disks (such as USB flash drives or other media) to make it easier to select the correct disk. To view disks, type "list disks".

Above, I typed "select disk 1" because I could see that Disk 1 was the correct disk by its size. The larger drive is my hard drive, I did not want to select that.

Step 3: Delete Partitions

Once you have selected the disk, you will want to list all of the disks on the partition by typing "list partition". In the picture above, I only have one partition left to remove. Type "select partition 1" and then "delete partition". Repeat for every partition listed.

You may want to write "list partition" after deleting each partition to make sure everything is going as planned. This is not necessary, but it's a good idea when using DiskPart for the first time.

Step 4: Create Partition

To begin using the SD card again, we need to create one large primary partition (as SD cards have by default). Type "create partition primary". Typing "list partition" shows that a new primary partition has been created.

If you want to see other options, you can also type "create partition" and various options will be shown on the screen.

Step 5: Reformat Disk

After repartitioning the disk, you can reformat the SD card like normal. This needs to be done before the SD card can be used.

If you aren't familiar with formatting a disk, you can choose the same options as above. The "Volume label" is whatever you want the SD card to be named. The other options should be selected by default. I highly recommend selecting "Quick Format". This will make formatting much faster.

DiskPart is a great tool because it doesn't take much time and doesn't require that you install any extra tools or software on your PC.