Turn Your PC into a Commodore 64 and Play Every Game For Free
14th February 2021How To Win At Retro Games Using Snapshots – Get To Those Higher Levels!
27th February 2021Fix Your SD Card After Using It As a Raspberry Pi or Linux Boot Disk
When you burn an SD card to act as a boot disk for your Raspberry Pi or to install another version of Linux, the SD card is formatted in a special way that means is no longer compatible with Windows based machines. When you’ve finished using the SD card and try to reuse it as a normal SD drive you can’t get Windows to recognise it. It can’t save files to it and you can’t reformat it to make it work again.
The SD card is still perfectly okay it’s just Windows is no longer able to use it.
To reclaim the SD card we need to use some low level formatting techniques to completely clean it and then rebuild it as a Windows compatible drive.
Using diskpart To Clean and Reformat An SD Card or USB Drive
diskpart is a command line tool built into Windows that allows us to bypass the normal Windows file management system and talk directly to the disk drive, or SD card, or USB drive. To access diskpart you need to open a command prompt with administrator access. To do this press your Windows key and type, cmd. You should see a dialogue open showing the Command Prompt options. Click the Run As Administrator option.
This will open up a black command prompt window which allows us to talk directly to the Windows operating system using text commands. To start the diskpart application simply type,
diskpart
and press the return key.
The prompt at your cursor should change to show DISKPART> which indicates that you’re now running the correct application.
Selecting the Correct Disk
diskpart is a very powerful tool for controlling any disk drive connected to your computer. This includes all of your hard drives. It’s VERY IMPORTANT that you ensure that you are working on the correct disk drive before you run any of these commands. We’re going to be completely wiping the SD card, but if you run the commands on one of your hard drives by mistake you will completely wipe that instead. You won’t be able to recover this error. So be warned.
To identify which drivers which we need to ask diskpart to list all the drives it can see. The command for this is
list disk
From my screenshot it’s quite easy to see that Disk 3 is my 16 GB SD card. If you’re not sure which one is which simply unplug your SD card, the list disk command, make a note of the drives listed, then reinsert your SD card and run the list disk command again. You should be able to see which drive is the one you’ve just inserted.
We now need to make sure that diskpart has selected the correct disk. Making note of the disk number for your SD card use the following command,
select disk 3
replacing the number 3 with the number displayed in your list of disks.
I always advise you to run the list disk command one last time just to confirm that the correct disk has been selected. If you look at the screenshot below you’ll see that my Disk 3 has an asterix beside it showing that it is selected.
Cleaning the SD Card
The actual problem stopping Windows from using the SD card is the way the disk has been partitioned. To allow Linux to boot from the card it has to create a boot partition and other data partitions formatted for Linux machines. Before we can do anything else we need to clean these partitions from the drive.
For this we use the clean command.
Warning : make sure you have follow the steps above and are absolutely certain you have selected the correct disk. The clean command will irreversibly clean the currently selected drive.
Partitioning the SD Card
At this point we have an absolutely blank SD card. Not only does it not have any files on it but it doesn’t have anywhere we can put files. For this we need to create a data partition.
As we want to use this SD card as a simple file storage device we only need to create a single, primary partition that fills the entire storage space on the SD card. For this we use the command,
create partition primary
Formatting the SD Card
Now that we have a partition which creates space for files, we need to format this area so that Windows can use it. You have a choice at this point. We can exit from diskpart and use Windows Explorer to format the drive, or we can do it from within diskpart itself using command line commands.
format fs=Fat32 Quick
In this command we specify the file system as FAT32 which will make the SD card compatible with most computers including Windows, Mac and Linux. Other options are NTFS and exFat but you should understand what these are if you need to use them.
Note that when you run this command it might sit at 0% for a number of seconds and then suddenly jump to 100%.