How to avoid reformatting external sd card when "Issue with SD card" pops up again?


Question

The comments in Does “How will you use this SD card?” wipe data?
indicate that the second option in the dialog "Issue with SD card - Tap to fix", which is "Use for portable storage", will also format the external SD card.


My external SD card works without issue from the recovery and I can also mount it after boot from the terminal, but the system does not make it visible e.g. to the file manager app.


I have reinstalled lineageOS recently and until the fourth or so reboot the SD card was working flawlessly and I already used it with the apps that now no longer see it. At the moment, the phone takes long to start with the external SD inserted, and often crashes after unlocking.


How can I avoid reformatting it but still get a behaviour where it works normally and there is no such "issue with SD card" notification?


I have had this issue in the past as well, on different devices, running a different version of (stock) android, with a different SD card. Oftentimes, a reboot or a reinsert of the card would fix it temporarily. But what is going on and how do I actually fix, or at least circumvent, it?


Answer

fsck works surprisingly well. At least if you have root. Not sure if that's required but I'd guess so.


I have outlined my process in this answer and mostly wrote this question so that future visitors have it easier to find this solution with the phrasing as I used here. The relevant parts again:



  1. Figure out what your filesystem type is.

    I did that from the recovery terminal using mount and blkid because then there aren't so many other block devices around (e.g. all the magisk devices). My device was called /dev/block/mmcblk0p1 and of type exfat.

  2. Make sure the partition is not mounted. umount /dev/block/mmcblk0p1 should do the trick. Or boot to the system and since android detects an issue it does not mount it automatically. It looks to me like the available fsck is actually slightly different, at least in my case.

  3. Run the relevant command for your filesystem type. Use tab completion to see your options. My command was fsck.exfat /dev/block/mmcblk0p1. Depending on your fsck you can also provide it with the -y flag to auto-fix everything without asking you every time.


I have re-encountered this issue and fsck did not help me this time... It turns out that you can also turn off the device, remove the sdcard, mount it on your windows computer, and run chkdsk H: /F to find and fix more errors. (H: is your sdcard (adapt accordingly), /F makes it fix errors instead of only reporting them).


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes