Diskpart/etcher errors - Wiping a removable/SDcard on win10

Tools like etcher use diskpart 'clean' command to nuke the partitions. On windows 10 this often will fail everytime when you try to image a disk that was previously flashed with a bigger image, it seems to be 4GB+. Etcher will just give a generic error (and its written in javascript, what could go wrong!), but diskpart is the root cause.

etcher error

If you're using diskpart by hand and run clean it will say access is denied and to check the event log or such:

DiskPart has encountered an error: The request could not be performed because of
an I/O device error.
See the System Event Log for more information.

The event log will have an entry with something like this, which is not helpful

Cannot zero sectors on disk \\?\PhysicalDrive2. Error code: 5@0101000F

The trick is to zero the partition table so it stops getting hung up for who knows why. Of course, if you have a linux machine handy you can just write zeros to the whole device with dd, but you wouldn't be trying to use diskpart in that case anyway. (dd if=/dev/zero of=/dev/sd<5> bs=8M count=256)

So if you dont want to juggle machines or only have windows, there is a nice little freeware tool that will perform exactly the same thing, designed more for secure wiping disks by repeated writes, but you can do one pass and cancel it like 5% the way through, and then etcher will flash successfully.

The tool is "RoadKil's disk wipe" available here

August 25, 2018

Previous:Getting wine 3.0 working on ubuntu 18.04
Next:Comparison of BSD source trees