I accidentally removed a MicroSD card from an Android device running Android 12 while it was being ejected. This happened because it took longer than usual (less than a few seconds), and I pulled it out without looking at the notification. Now, when I insert the MicroSD card into any Android device, it tells me to format it to use it, as a problem has occurred. It also gives me the option to format it and extend the internal storage. The third option is to skip both and do it later, which keeps the SD card unreadable by the system. The MicroSD card contains a lot of data that’s important to me, and unfortunately, I had no backup, as I always considered my MicroSD as an external storage medium for such data. I would really appreciate any help on how I can resolve this issue and make the SD card data accessible again by Android. Thank you for reading! 🥲

Edit: Don’t ask me why or how. But I put the SD Card into a phone running Android 14, and booted it. The SD Card could be actually read by the phone after it finished booting. I turned the phone off again, pulled the SD card out and put it back into it’s original running Android 12 and magically it works again! My theory is that the Android 14 recognized and automatically fixed what was wrong and this made the card readable again to older Android versions.

Thanks to everyone who commented!

  • nossaquesapao@lemmy.eco.br
    link
    fedilink
    English
    arrow-up
    22
    ·
    edit-2
    5 months ago

    Do you have access to a computer with an sd card reader? I believe the best and safest thing to do is to connect it to a computer, create disk image from it and try ro use a data recovery tool in the image file.

    Edit: if you only have the phone, maybe you could try looking for apps to copy a disk image from the sd card and to recover data or try using some terminal emulator or one of those apps that install a linux distro inside android to use the dd command and then use testdisk and photorec tools. I recommend the second option, because the tools are open sourc and well tested

    • ziviz@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      12
      ·
      5 months ago

      Definitely this. The data is not likely gone, but before doing anything that could make things worse, try and get a full copy of the SD card somewhere. From there you may safely try repairing the partition or data carving tools.

  • j4k3@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    arrow-down
    1
    ·
    edit-2
    5 months ago
    So Flash memory works in blocks called pages. The pages contain a header that ends in a few bytes that says what the rest of the page maps to.

    If the file was encrypted, you’re probably SOL. If it was not encrypted it may be possible to to recover some parts of the files. This is extremely advanced level data recovery. I only know the abstract basic principals and would likely struggle to figure this out and recover my own stuff if I ever needed to do this. I’ve only programmed microcontrollers and flash memory devices.

    A micro SD card contains a small microcontroller and some blocks of flash memory, although the microcontroller is transparent to the user and operating system… unless hacking with needle probes in a lab.

    So here’s the basics. Writing flash involves taking an entire Page of memory and zeroing it first. There is a tiny voltage booster circuit on the card that allows the page to get pulsed up and down in voltage a few times in order to completely zero the entire page without any remaining residuals. Once this is done and the entire page has been zeroed, only then is it possible to write the data into the bytes of the page.

    If you want to change a single byte level value in an address that already contains a value, first the entire page is copied to a blank page in another location, then the old page is pulsed a few times, then each value is transferred back into the old page except that the new value that needed to be changed is now set to the new values.

    This is the proper way to write flash at a basic level. If the power is lost in the middle of this cycle, the worst case scenario is that the new updated value was not written. The page in question should never be “missing” because the header record should always point to either the original or copied page. One of the two should always be present and complete… in a proper setup. Obviously, it might be faster to simply use some RAM to hold the page, erase the old page and rewrite it. I have no idea what size pages are in modern SD cards, but on hobby class microcontrollers I have used the pages were 4096 bytes, IIRC. My understanding is that most SD cards use an 8051 clone micro, so it is probably a similar size.

    So here’s the thing, the bulk of the data is always there. Somewhere deep down inside you likely already knew this. It is why you’re supposed to overwrite an entire drive instead of the “quick” erase in most formatting tools. The quick erase is simply deleting a tiny header file that says what exists where on the drive. Similarly, some part of your SD card there is a page or few where the header has been screwed up. Your OS is looking at this header info and seeing a mismatch of garbled junk and saying f-that bs.

    Generally, recovery would involve dumping the raw contents of the flash memory as hexadecimal, being super familiar with what you’re looking at and knowing how to find the page that is causing the error. Generally I assume you’d need to replace the bad page with a good header and it would then work. There are services for this kind of operation; data recovery. In practice, this has a few more layers of complication. Pages can be placed in different locations that enable wear leveling so one area of memory is not over utilized. There is also a table of bad blocks/pages that the micro knows to skip, and there is usually a bit or address in the page that is used to detect errors that may have occurred.

    This is pretty much everything I know on the subject. Hopefully it helps you understand the abstract nature of what is happening. In the simplest of terms, flash memory is like writing a long essay with an ink pen and where you can not make mistakes or use whiteout. If you need to make a change, you must write out the entire page all over again. This process is what is so time critical that you must “eject” the drive.

  • rufus@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    5 months ago

    Plug it into a computer and see what the computer says.

    I usually use Linux for that because it offers good error messages and I know the tools. But other operating systems might help, too.

    And if you start writing to the card or executing recovery tools, make a backup / image first.

    If the files are very important, maybe don’t tamper with it and ask for help. Like a repair shop, your local Linux community or any trustworthy computer expert friend.

    The biggest enemy is probably encryption, if it’s encrypted. The files are definitely still there if you just ripped it out. In the old days you could just run a recovery program and get everything back.

  • TheBigBrother@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    1
    ·
    5 months ago

    As far as I know you are screwed but maybe using disks program in Linux can help you to fix if the header is broken but I am not sure. You will have to try by yourself.

  • pturn1@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    5 months ago

    Have a look at Spinrite. Works wonders on HDDs, and I believe a lot of development has gone on to cater for SSDs as well.

  • Martineskirt@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    5
    ·
    edit-2
    5 months ago

    Idk if comments boost post but boost.

    Edit: damn, I commented to give op more reach and got downvoted. 😂