Repair your Raspberry Pi's SD Card with Diskpart

Updated 24 April 2017

If you’ve ever pulled an SD card out of a Raspberry Pi and attempted to re-flash it with another disk image, you may have noticed something funny…

sd-card-is-broken

sd-card-repair"My X Gigabyte SD card has shrunk to a few megabytes! What gives?" No, your SD card isn’t ruined, there’s just a few steps we need to follow to clean up our card and make it good as new.

We’re going to use a windows utility called diskpart. Be aware that this process will wipe everything on the SD card.

Start off with your SD card unplugged from your computer.

Open command prompt (Hold the Windows Key and press R to access the run menu. Type in cmd and hit enter). Windows 10 Users, you have a cool "power-user" menu available when you hit Win + X. You can run command prompt and other utilities from here.

run-command-prompt

At the prompt, enter the command diskpart

command-prompt-run-diskpart

Another window with the diskpart utility opens.

List the available disks with list disk

Looking at the list, we can see all the storage devices connected to the computer, in this case I have only the main hard-drive listed.

diskpart-list-disk

Connect your SD card to the computer now and run list disk again to see which disk we’re interested in. I’m using an 16 GB card, which has appeared as Disk 1 and 14GB. The capacity will never fully match what your card is specified as, for a few technical reasons.

I’m going to execute select disk 1, where you will replace the number 1 with whichever number corresponds to your SD card.

diskpart-select-disk

Execute list disk again and you’ll see that your SD card should be selected, as indicated by an asterisk (*)

We’re going to clean the SD card, and reset it’s configuration:

Execute clean which resets the SD card configuration and then create partition primary

diskpart-clean-create-partition

Once this step is completed, you should see your SD card reappear in the file explorer. You should receive a prompt that the SD card needs to be formatted. Format your card with the default settings and you’re good to go! You’ll be able to re-image the SD card for use in a Raspberry Pi, or return it to whatever digital camera you “borrowed” it from!

format-sd-card                            sd-card-is-fixed

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.