How To Reformat SD Card to use it NormallyWhen using SD cards in a Raspberry Pi, the software will repartition the card in a way in prevents Windows from reading or formatting it. Here's how to fix that.
When using tools like Etcher to write disk images to an SD card (or USB thumb/flash drive) they will often re-partition the drive and use Linux file systems. If you want to use these cards again in a camera or on Windows you may notice that the SD card capacity has shrunk down to only a few megabytes, or you can't read the card at all!
Fret not. I'll show you how to restore the SD Card to normal in Windows.
Caution. The process here will erase all data on the drive selected. Make sure you select the right drive and that you are OK to lose all data on the SD card.
First, when you insert the SD card into the computer you will probably get a message saying that you must format the drive before you can use it.
Clicking on "Format disk" will show another popup screen with details on the disk and allow you to start the format process. However, you will notice that the capacity is greatly reduced. This is because the first partition was used by Raspberry Pi as a bootloader. The rest of the data is on another partition which is hidden (for now).
Once the format is complete you can see the drive structure in Disk Manager (Start -> Create and Format Hard Disk Partitions)
Notice that the drive has two partitions and unallocated (free) space. We need to delete the partitions and create a new partition equal to the capacity of the drive. Right-click on the partitions for the SD card (NOT the hard drive or any other drives you may have installed!) and select delete.
You will then have a large chunk of unallocated space. Usually (and if you're very lucky) you can right-click this unallocated space and create a new simple partition. If that works for you great, your card is now fixed!
If not, clicking the menu item will do nothing, so carry on with the steps below.
Reformat SD Card in Windows
Open up your command terminal of choice and enter DISKPART
and hit enter.
We need to be very careful to select the right disk here, or else you could lose data or wipe Windows from your computer.
Type in LIST DISK
and hit enter.
This will show a list of all the physical disks attached. Carefully check which one is the SD card. For me, it is disk 1.
Change the active working drive by typing SELECT DISK 1
taking care to enter the correct drive number from the disk list.
You can then use LIST PARTITION
to list the partitions on the disk. If you deleted them in Windows Disk Manager then no partitions will show.
We can now refresh the partition table on the SD card with the CLEAN
command.
And finally, we can create a new partition by entering CREATE PARTITION PRIMARY
.
You can now exit the diskpart
tool, eject the SD card and re-insert it.
You will again see a message indicating that you need to format the drive before use. Proceed to do so and this time notice that the capacity has been restored.
Once the format is complete your SD card has been restored to its original condition and can now be used as normal.
Reformat SD Card in Linux / Mac OS
You can follow a similar process in Linux using FDISK
or CFDISK
.
In a terminal, start fdisk /dev/sdx
where /dev/sdx
is your SD card device (may depend on the Linux distro you're using, see below). You can then delete all existing partitions on the device by typing d, and then adding a single new partition & format it. You can also just type n to create a new partition table and start laying everything out.
cfdisk
is also another viable tool, which is basically fdisk
with a greatly improved user interface. In both cases, once the drive is formatted, you will lastly need to mount it.
If you're unable to determine the proper device, remove the SD card, run fdisk -l
, and then re-run it with the SD card inserted. The SD card is just the device that has been added.