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.

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.

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.

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.

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?

  • 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.

  • 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.

  • 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.”

  • Djx Jimenez

    when I tried to clean the partitions I got this error
    “the request could not be performed becasue of an I/O device error”

  • Abhay Kagalkar

    I want to format Sandisk 32GB memory card.. I tried to format by diskpart and many other ways I am unable to format help me..If I insert that in camera it is showing the SD card is right protected but I haven’t put any password for it… Please help me

  • ‫عـلـى فتحى‬‎

    hello, after Type create partition primary, message said: diskpart encountered an error. the device isn’t ready. see system event log for more informmation

  • Thanks for this, fixed my RetroPi SD card in less than a minute.

    I downloaded EaseUs and it hijacked my browser and installed a lot of junk programs on the sly. Stay away! This article is all you need!

    Thanks again.

    • Actually, what I generally find is that whenever I install these programs that people allege install junkware “all by themselves,” I come out the other end completely unscathed. What I get from this is that people are really bad at reading on-screen instructions, and don’t hit “Decline” or untick the checkbox for installing junkware, and then complain that the program did it against their will, when it couldn’t be farther from the truth.

  • Cool Dude

    I have SanDisk 32GB class 10 memory card which shows error while formating into mobile phone, I tried in my Laptop but it is not detecting but when i use DISKPART the i can see the disk in the list. I can not format it. i can not use it neither in mobile nor in Laptop. Please help me in this. I have putted the DISKPART error msg below:

    DISKPART> list disk

    Disk ### Status Size Free Dyn Gpt
    ——– ————- ——- ——- — —
    Disk 0 Online 298 GB 1024 KB
    * Disk 1 Online 29 GB 0 B *

    DISKPART> select disk 1

    Disk 1 is now the selected disk.

    DISKPART> clean
    DiskPart succeeded in cleaning the disk.

    DISKPART> create partition primary
    Virtual Disk Service error:
    The operation is not supported on a non-empty removable disk.

    DISKPART> select partition 0
    Partition 0 is now the selected partition.
    DISKPART> active
    The selected disk is not a fixed MBR disk.
    The ACTIVE command can only be used on fixed MBR disks.

    DISKPART> select partition 1
    Partition 1 is now the selected partition.

    DISKPART> active
    The selected disk is not a fixed MBR disk.
    The ACTIVE command can only be used on fixed MBR disks.

    DISKPART> format fs=ntfs quick

    There is no volume selected.
    Please select a volume and try again.