You have loaded a Linux image onto an SD card in Windows using a tool like Win32DiskImager, and have extended the partition in Linux, and now you want to format the SD card (in Windows) and start again.

You put the SD card into the SD card reader and it shows up as 56MB in size (or something like that) which is much less than the capacity of the card (in my case 16GB). This is the unused space on the card that Linux hasn’t claimed when partitioning. If you try and format this in Windows, all you will do is format the 55MB unused space (and render the card unusable to Linux). If you try to run Win32DiskImager to load the image again it will complain because there is not enough space (flashnul -L will not work either).

This is the scenario for a Windows laptop owner (like me) who wants to reset the Debian image on the SD card for a Raspberry Pi so I can start fresh. All of the solutions that I found involved installing a Linux VM on my laptop. This is OK, but I stumbled upon an easier method using a scary little tool called flashnul.

WARNING: HERE BE DRAGONS
Don’t attempt this unless you are a Windows expert. You can cause serious damage to your computer’s hard-drive with a tool like flashnul. You could wipe all of your data and never be able to get it back.

Right, if you are still with us, the solution is to use flashnul to erase the boot sector of the SD card, so that Windows discovers the true size of the card. Obviously if you erase the boot sector of the wrong drive, well, let’s just say it’s not going to be a fun day. One more problem, the instructions are in Russian. So really, unless you are a Russian speaking Windows fourth dan blackbelt, well it might be time to get the hint and read a different blog.

Excellent! Welcome friend, we have been waiting for you… pass this final test and then, when they knock on the door, follow the white rabbit…

Download and install the latest version of Flashnul.

First, in a Windows Command prompt, running as Administrator:

flashnul -p

This will give you a list of physical and logical drives. Take note of the physical drive number of the drive that you are certain is your SD card. It will have the same size as is reported by Windows.

Here are the flashnul instructions translated from Russian to English.

Scroll down to “A detailed description of the modes” and read the instructions for Mode-B, that’s switch -B, comrade. I’ll leave it to you to figure out the syntax for this command, which will blow away the boot sector of the physical drive that you specify. Good luck.

OK, now eject the SD card, wait a 10 seconds and put it back in again. Wait until Windows recognises it again and you should now see the full capacity of the card reported by Windows (or close to it).

Now you can copy a Linux image onto the card using Win32DiskImager.

  1. dansraspberrypi posted this