Tell me more ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I wish to reformat my SD card to use normally again (it currently has one 78MB FAT32 partition and one 3.9GB Linux partition). How do I do this (on Windows/Mac/*nix)?

share|improve this question
Well it worked for me on W7..Thanks much – cdn_NewB Apr 4 at 4:16

6 Answers

up vote 19 down vote accepted

Windows

  1. Insert the card into your card reader.
  2. Go to my computer and locate the drive letter assigned to the card.
  3. Right click and from the options menu select format.

Mac

  1. Open the Disk Utility application and select your SD card.
  2. Select "Erase" from the submenu.
  3. Choose "FAT" from the re-format menu.

Linux

Assuming that your SD card is already mounted.

  1. Find where the SD card is mounted.

    Enter the following on the command line:

    sudo mount,

    and enter your password to see the directory list). The SD directory will be something like: /dev/sdxy (where x is a letter and y is a number - be very careful here as entering the wrong number below could result in you deleting your current install - you can usually identify the correct number by a combination of the device size (number of blocks), id and system type).

  2. Delete any existing partitions (from the SD card only).

    Enter the following on the command line (replacing x with the letter identified in step 1):

    sudo fdisk /dev/sdx

    • list the existing partitions by typing p.
    • delete them by issuing the d command (repeat as needed until all partitions have been removed).
  3. Create a new partition.

    • Type n to create a new partition.
    • Type p to create a primary partition.
    • Type 8192 to select the sector. (See note)
    • Press enter to select the default last sector.
    • Type t to change the type of the partition.
    • Type b to select the FAT32 type.
    • Type w to save (write the changes to disk).
  4. Format the new partition

Enter the following on the command line to format the new partition (replacing x with the number identified in step 1).

mkdosfs -vF 32 /dev/sdx


Note:

You shouldn't select the first sector when repartitioning the SD card. The way SD cards work physically means to write data, the electronics have to delete a fixed amount of data, called an Erase Block. Partitions will be more efficient if they are aligned to Erase Blocks. A lot of large SD cards seem to use a 4MB erase block size, but this is by no means standard. Assuming a 512B sector size, the second erase block starts at 8192, which is why it is suggested.

share|improve this answer

You can use DISKPART in Windows, or the equivalent fdisk command under Linux/Mac.


DISKPART (Windows)

Start a command prompt, and start the DISKPART console. List all of your disks by typing LIST DISK, then select the proper disk with SELECT DISK # (where # is obviously the SD card). You can then type CLEAN (MAKE SURE YOU SELECTED THE PROPER DISK!), and it will clear the partition table on the card.

To create a primary partition to reuse the space on the card, type CREATE PARTITION PRIMARY. This will then reallocate the previously "cleaned" space.

To format, type FORMAT FS=FAT32 QUICK, and finally, to reassign a drive letter, type ASSIGN.

If you're unable to determine the proper disk, remove the SD card, run DISKPART and LIST DISK, and then re-run it with the SD card inserted. The SD card is just the disk that has been added.


FDISK / CFDISK (Linux/Mac)

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 an 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.

share|improve this answer
@AlexChamberlain in DISKPART, you can generally tell by the capacity of the disk. Once you select a disk, you can also call LIST VOLUME to see all the drive volumes and their labels (so long as your SD card's name shows up, you have the right device). If you're using fdisk, type p to print the partition table and check that the volume labels are correct. If you're using cfdisk, it should show you the volume labels right after you start the command on a device. – Breakthrough Aug 4 '12 at 14:12
Sounds good! Let's delete this comment thread to clean up! – Alex Chamberlain Aug 4 '12 at 14:26

On your camera

Most cameras have a built in Format function, which will use a single FAT partition. My camera even puts it on an erase block boundary.

For example, on my Pansonic Lumix, having inserted the card and from any mode, the menu as a Format entry. Selecting it brings up a menu asking me to confirm I wish to delete all the data on the card. Selecting Yes formats the card.

share|improve this answer
Great answer, as long as Tom wants to format it for use in a camera. – Jivings Aug 4 '12 at 19:46
:) It will be one FAT partition, starting at the second erase block. – Alex Chamberlain Aug 4 '12 at 19:47
It'll be FAT Formatted like any other FAT formatted device… it's not camera specific. However, he'll have to delete various folders created like "DCIM" – XAleXOwnZX Aug 4 '12 at 22:38

You can use the official SDCard.org application (Windows / Mac).

https://www.sdcard.org/downloads/formatter_3

It's fairly simple and reformats the SDCard in FAT32. There are options for LBA-adjustment and wiping / erasing as well.

share|improve this answer

I had a very similar issue. My set up: Computer running on Windows 7 and Sandisk ultra card 16GB.

I wanted to format my card for installing Open Elec. So I downloaded SD formatter and tried formatting it. It became a 64 MB card! Tried multiple settings, tried diskpart on CMD and clean format using computer management/disk management console - no luck. Always winimg writer claimed there was no sufficient space in the card. Earlier (that is before using SD formatter) it will expand the space and will install and I subsequently used expand command on Rpi terminal. So here is what I did:

Downloaded berryboot (note it is 28 mb!) wrote the image on SD card and booted the Rpi. Berry Boot reformatted the same using its own in built prgm. Now I took the card out and formatted it using the format tool on windows with FAT. Took the card out and re inserted. Now it reads 14.4 GB! Any one stuck like this can try this out.

share|improve this answer

No good on Mac with latest OSX. Card cant be erased in any way.

share|improve this answer
Nonsense, what about fdisk? – Jivings Mar 29 at 9:34
@Jivings since I can't edit (due to my FAQ spree), how should I respond to this question while reviewing: flag, comment, etc? – xxmbabanexx Mar 30 at 5:47
@xxmbabanexx Downvote probably. It is an answer, it's just wrong. And that's not a flaggable offense. – Jivings Mar 30 at 9:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.