Accidentally removing a card reader without first ejecting the Sandisk 256GB MicroSD in it has caused the SD card to become corrupt. When inserting it now, OSX prompts that it cannot read the card and offers an option of initialising it. This doesn't work, and Disk Utility gets stuck "waiting for the disk to re-appear" when I try to format it. In Disk Utility and in /dev list, the card shows up as 8MB rather than 256GB. I am hoping that I haven't damaged the controller and that the card might be fixable. Any thoughts?
Just setting up a new volume is pretty easy with:
diskutil eraseDisk ExFAT SD256 disk44
(I chose disk44 above for the example but you will need to choose your disk number after making sure you're not erasing the boot volume or other critical disks - check your backups and disconnect any external drives you aren't prepared to restore from backup)
See Cannot unmount disk0 resource busy and When erasing media in Disk Utility, how can I change the default format? for a little extra visual or other options of
diskutil that work on a volume instead of destroying all data on the disk.
I had the same issue using a SanDisk Ultra 256GB MicroSDXC UHS-I Card. Card became corrupted when a child removed it during a 100 GB data transfer process using macOS 10.14.3 (Mojave). Long story short the SD card was recoverable but not using
dd on Mac.
What worked for me was to boot from a USB card running Tails using the
Opt key at boot on my Mac then use the graphical
Disk Utils app installed to format the card without a partition table.
After the reboot Mojave presented a dialog stating it couldn't read the card and provided an
Initialize... option which I was then able to use to successfully format (erase) and repartition.
I ended up using a
GUID Partition table with an
ExFAT file system for cross-platform portability. The lesson learned here for me was never let a kid near an SD card during a back-up process.
Edit: Turned this into a blog post with photos.
When all else fails... I try the other platform -- find a PC that supports the SD card and try formatting it there.
(Back in the day, I got my first 1GB USB stick from a friend who often brought it to me for reformatting on my eMac (1GHz G4!) after removing it from his PC without ejecting.)