How to partition an SD card/flash drive with DiskPart on Windows

If you’re like me then you write images to SD cards and USB flash drives on a regular basis to test out different Linux distributions. Often times doing this however splits the space on a flash drive into multiple partitions and in order to utilize all of the space again in Windows you have to re-partition the drive. For the longest time I had always used Linux or gParted to accomplish this but then I discovered that there’s a command-line utility called DiskPart, which is included in Windows. So let’s see how we can partition an SD card/flash drive using DiskPart.

The first thing we need to do is open DiskPart. Press Windows Key + R and the Run dialog should popup. Type in diskpart and hit Enter.

Run dialog

Once DiskPart comes up, type list disk. This will show you all the disks that are attached to the system. You’ll want to note the number of the one that is your sd card/flash drive. You should be able to distinguish it based on it’s small size compared to your hard disks.

List disk

In this case mine is Disk 3, so next you need to select the disk by typing select disk 3 (obviously replace 3 with whatever your drive number is). After that you can type list part and it will show you what partitions are already on the disk.

List part

Next to remove all the partitions from the disk just type clean. Afterwards type list part and the console should say that there are now no partitions on the disk.


Now that it’s cleaned off, we just need to make a new partition. Type create partition primary and this will create a new partition that fills the available space on the disk. You can type list part to confirm that the new partition has been created.

Create partition primary

After that navigate to the drive in Windows Explorer and you should be able to format it now with all the space reclaimed.

  • Kyonkanno

    great guide!

  • bunny

    what if i want to create a secondary partition on the same usb drive is there any way of doing so???

  • lijoh

    I thought we were trying to partition the drive into more than one partition?

  • suebellqmz

    This Kingston flash drive is wonderful – sturdy, solid usb thumb drive seems very well-made, sturdy, and affordable – I love this thumb drive. It’s hale and hearty, and it holds massive amounts of data.

  • livlowewv4

    This SanDisk flash memory card is great – good performance, affordable price – Great product, good quality, nice package. Everything works as I expected.

  • victorleite

    Straightforward.. THANKS!

  • Paul

    I want to partition a flash drive into 2 partitions. Your not partitioning a flash drive at all.

    • dukpluk

      Actually, it is partitioning, just not MULTIPLE partitioning. Check your facts before checking others.

  • post master

    Good instructions, worked fine.

  • bAN01TgAZ

    Right click My Computer, select Manage, goto Disk Management, create primary partition with the first drive, give it 50%, then create another simple partition in the remaining space

  • Abdul Quddus

    Thanks a lot..Its very easy and Worked 100% :-)

  • Reed R.

    Thank you so much! I spent what seemed like forever looking for just a simple way to undo some partitioning done to one of my SD cards by a RasPi enthusiast. So many garbage answers about using android apps and using downloaded drivers and modifying text files and all sorts of ridiculous crap. Google needs to boost this answer’s ranking.

  • dukpluk

    Thank You! This worked to undo some partitioning errors I made. Very quick and easy.

  • Deepak Raj Kurrey

    Thanks Buddy, Helped me a lot….Nice Presentation….but….you forgot to suggest users “to get admin privilege for DiskPart command”

  • aj

    after creating the partition also i am unable to format my flash drive and i cant use it

  • Mick McCall

    “DiskPart has encountered an error: The system cannot find the file specified.”