diskpart clean; playing with fire

The other day I was trying to reset the size of a SD card I had imaged for a raspberry pi project. Since the drive was reporting 50mb verse it’s true size of 8gb. Let me also say this was my home pc.

One way to reset the size is using diskpart in windows. You can run diskpart from a command prompt. The commands I ran are  as follows.

diskpart

list disk

select disk 8

Oh wait, that isn’t the right thumb-drive. So i swapped it out with the correct one. However, I reran “list disk” once again but didn’t pay attention really. I saw disk 8 and said ok, there it is and selected it.

Then I deleted the partitions to free up the unallocated on the SD card using delete partition.

delete partition 1

Then the idea in my head was, clean the old test data off so I ran “CLEAN”. So I rescan the disks and see that my thumb-drive appears ready. So I image the SD card with the latest raspbian, pull the thumb-drive out and start working on the pi.

clean

close disk part

I start setting up the raspberry pi and a few hours later I check my PC backup drive attached via usb looking for another image,  the drive letter isn’t there. So I say, that’s strange, pull the drive and re-attach, no drive letter… So I go back in to disk part and notice it does not have any partitions. Noooo!

It turns out when i swapped the SD cards the drive numbering changed moving my external usb3 backup drive to #8 and the SD card became #9. I lost everything on the backup drive because “CLEAN” wipes the drive. More than deleting the partition, I wiped everything on the 3TB hard drive. Since you are using disk part the wiping occurs in the background, you don’t see it happening unless you pay attention.

Just a lesson learned regarding diskpart, don’t be hasty. Double check that you select the correct disk or partition or volume before you do any deleting or cleaning! Or better yet, do it from a pc you don’t mind losing data from.

Lessons learned..

 

A few ref’s:

https://technet.microsoft.com/en-us/library/cc766465%28v=ws.10%29.aspx

https://msdn.microsoft.com/en-us/library/jj979618%28v=winembedded.81%29.aspx

http://www.sevenforums.com/tutorials/52129-disk-clean-clean-all-diskpart-command.html

http://www.raspbian.org/

Share

UA-8105999-2