Why can't I write to the last block of my SDXC card on my MBP?

I have a 64GB SanDisk SDXC memory card which I would like to use with my MacBook Pro and its SD card slot. However, I am having some trouble formatting/partitioning my SD card and I can't figure out what's going on.

  • When I insert the SD card into the slot, I get the following from Lion: The disk you inserted was not readable by this computer. Initialize... Ingore or Eject

  • If I open up Disk Utility, I see the disk listed as Apple SDXC Reader Media and when I try to format from "Erase" tab (as exFAT or any other format), I get the following error: Disk Erase failed with the error: Unable to write to the last block of the device.

A little background: the SDXC card was working fine when I first purchased it. But then I started using sabnzbd http://sabnzbd.org/ to download and write files directly to the SD card. Something happened (I can't remember what the error was!) and since then I've been unable to write to my card. I've been trying to format it to solve the problem, but it looks like the issue runs pretty deep.

What is the best way to format the card to exFAT via terminal? That may be the next thing I try.

Do you have any suggestions for formatting/fixing this SD card?


Solution 1:

The following procedure should format your SD card to make it usable again and cause bad sectors on the card to be remapped if that is part of your problem. Warning, erasing the wrong drive could make you cry so make sure that you know what you are doing.

  1. Before inserting the SD card into your Mac, make sure that the write protect (lock) switch is turned off
  2. Open a Terminal window and type diskutil list
  3. Insert card
  4. If an OS X messages pops up asking you to "Initialize... Ingore or Eject", choose "Ignore"
  5. From the Terminal windows, type diskutil list once again
  6. Examine the difference between the two Terminal outputs to determine the disk number for your SD card. You should be looking in the left most column for something like /dev/disk3 or 4 or 5 etc.
  7. Now type diskutil unmountDisk /dev/disk# where # is the number you determined earlier
  8. Here is where you must be VERY CAREFUL. Enter the following sudo dd if=/dev/zero of=/dev/rdisk# bs=64k and be sure to replace the # with the previous disk number. Note the 'r' in front of the rdisk in case you are typing this by hand instead of copy/pasting the text. You should be prompted for your password to run this command because it is dangerous
  9. Be patient until it finishes. You can estimate time by opening the "Activity Monitor" application in Utilities and clicking on the "Disk" tab. At the bottom you should see the Data written/sec in red. It should be some number in MB like 5. (64 x 1000 / n) / 60 = minutes until it finishes where n is the rate in MB that you just determined or 5 in my example
  10. Once the previous command completes, the card should be completely erased and ready for formatting. At this point you can close your Terminal and open the Disk Utility application to create an exFAT partition like you were trying to do earlier.