Repair filesystem on Android SD card?

Hi, folks!

I have a MicroSD card that I use in my phone (Moto G6 running Android 9.x), and recently one of my games had become extremely crash-happy, so I looked into things a bit. I found a file within its folder on the SD card that wouldn’t delete, and therefore neither would the folder. I was able to work around this issue by renaming the folder and reinstalling the game, but the crashes continue, and I suspect this may be due, in part, to something fishy with the filesystem on the SD card. Android’s “check” (the one it does before mounting the card if you have manually ejected it) doesn’t find anything wrong, so I physically pulled the card and plugged it into my PC using a USB adapter.

The idea in my head at the time was that, given the proper tools, Linux can handle almost any filesystem known to man, so I ought to be able to run a quick fsck and get back to business—or back to gaming in this case!

However, the normal tools don’t want to mess with the filesystem on there. A little research showed me that Android uses non-standard flavors of filesystem on its external storage. I don’t want to force anything and damage the other data on the card, so I’m asking here in the hope that someone else may have dealt with a similar situation before.

I know the card shows up as /dev/sdd:

$ sudo parted --list

...
Model: Multiple Card Reader (scsi)
Disk /dev/sdd: 64.1GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name            Flags
 1      1049kB  17.8MB  16.8MB               android_meta
 2      17.8MB  64.1GB  64.0GB               android_expand

So it seems the card is using GPT. That’s about all I know. fsck wisely refuses to operate on either partition:

$ sudo fsck -V /dev/sdd1
fsck from util-linux 2.36
[/usr/bin/fsck.exfat (1) -- /dev/sdd1] fsck.exfat /dev/sdd1 
exfatfsck 1.3.0
Checking file system on /dev/sdd1.
WARN: file system in sectors is larger than device: 125104128 * 512 > 16777216.
ERROR: file system in clusters is larger than device: 488664 * 131072 > 16777216.
File system checking stopped. ERRORS FOUND: 1, FIXED: 0.

$ sudo fsck -V /dev/sdd2 
fsck from util-linux 2.36
[/usr/bin/fsck.ext2 (1) -- /dev/sdd2] fsck.ext2 /dev/sdd2 
e2fsck 1.45.6 (20-Mar-2020)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdd2

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  ...

I also have a VM with Android x86 9.0 installed, however when I connect the USB card reader to that, it offers to “prepare” the USB device for use, which I’m pretty sure would actually erase it. I would rather not do that just yet. :slightly_smiling_face:

System info in case it’s useful…

inxi output
$ sudo inxi --admin --verbosity=7 --filter --no-host
System:    Kernel: 5.4.58-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.1.0 
           parameters: BOOT_IMAGE=/boot/vmlinuz-5.4-x86_64 root=UUID=0b7011d2-bf5d-4d60-9441-083b80f54009 rw quiet apparmor=1 
           security=apparmor resume=UUID=d6bd5c20-26db-4bfa-9fe4-2de3cd57abbc udev.log_priority=3 
           Console: tty 1 wm: kwin_x11 DM: SDDM Distro: Manjaro Linux 
Machine:   Type: Desktop Mobo: ASUSTeK model: ROG CROSSHAIR VII HERO v: Rev 1.xx serial: <filter> UEFI: American Megatrends 
           v: 2501 date: 07/12/2019 
Memory:    RAM: total: 62.78 GiB used: 44.61 GiB (71.1%) 
           Array-1: capacity: 128 GiB slots: 4 EC: None max module size: 32 GiB note: est. 
           Device-1: DIMM_A1 size: 16 GiB speed: 2133 MT/s type: DDR4 detail: synchronous unbuffered (unregistered) 
           bus width: 64 bits total: 64 bits manufacturer: Corsair part-no: CMK32GX4M2B3200C16 serial: N/A 
           Device-2: DIMM_A2 size: 16 GiB speed: 2133 MT/s type: DDR4 detail: synchronous unbuffered (unregistered) 
           bus width: 64 bits total: 64 bits manufacturer: Corsair part-no: CMK32GX4M2B3200C16 serial: N/A 
           Device-3: DIMM_B1 size: 16 GiB speed: 2133 MT/s type: DDR4 detail: synchronous unbuffered (unregistered) 
           bus width: 64 bits total: 64 bits manufacturer: Corsair part-no: CMK32GX4M2B3200C16 serial: N/A 
           Device-4: DIMM_B2 size: 16 GiB speed: 2133 MT/s type: DDR4 detail: synchronous unbuffered (unregistered) 
           bus width: 64 bits total: 64 bits manufacturer: Corsair part-no: CMK32GX4M2B3200C16 serial: N/A 
CPU:       Topology: 8-Core model: AMD Ryzen 7 2700X socket: AM4 bits: 64 type: MT MCP arch: Zen+ family: 17 (23) model-id: 8 
           stepping: 2 microcode: 800820D L1 cache: 768 KiB L2 cache: 4096 KiB L3 cache: 16.0 MiB bogomips: 118221 
           Speed: 3216 MHz min/max: 2200/3700 MHz base/boost: 3700/4350 boost: enabled volts: 1.2 V ext-clock: 100 MHz 
           Core speeds (MHz): 1: 2187 2: 1905 3: 2006 4: 2012 5: 2213 6: 2168 7: 2190 8: 2190 9: 1905 10: 1884 11: 2187 
           12: 2163 13: 2186 14: 2180 15: 2186 16: 2007 
           Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1 bmi2 bpext clflush clflushopt clzero cmov 
           cmp_legacy constant_tsc cpb cpuid cr8_legacy cx16 cx8 de decodeassists extapic extd_apicid f16c flushbyasid fma fpu 
           fsgsbase fxsr fxsr_opt ht hw_pstate ibpb irperf lahf_lm lbrv lm mca mce misalignsse mmx mmxext monitor movbe msr 
           mtrr mwaitx nonstop_tsc nopl npt nrip_save nx osvw overflow_recov pae pat pausefilter pclmulqdq pdpe1gb 
           perfctr_core perfctr_llc perfctr_nb pfthreshold pge pni popcnt pse pse36 rdrand rdseed rdtscp rep_good sep sev 
           sha_ni skinit smap smca sme smep ssbd sse sse2 sse4_1 sse4_2 sse4a ssse3 succor svm svm_lock syscall tce topoext 
           tsc tsc_scale v_vmsave_vmload vgif vmcb_clean vme vmmcall wdt xgetbv1 xsave xsavec xsaveerptr xsaveopt xsaves 
           Vulnerabilities: Type: itlb_multihit status: Not affected 
           Type: l1tf status: Not affected 
           Type: mds status: Not affected 
           Type: meltdown status: Not affected 
           Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl and seccomp 
           Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization 
           Type: spectre_v2 mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling 
           Type: srbds status: Not affected 
           Type: tsx_async_abort status: Not affected 
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] 
           vendor: Sapphire Limited driver: amdgpu v: kernel bus ID: 0a:00.0 chip ID: 1002:67df 
           Display: server: X.Org 1.20.8 compositor: kwin_x11 driver: amdgpu FAILED: ati unloaded: modesetting 
           alternate: fbdev,vesa display ID: :0 screens: 1 
           Screen-1: 0 s-res: 2560x1440 s-dpi: 135 s-size: 483x272mm (19.0x10.7") s-diag: 554mm (21.8") 
           Monitor-1: HDMI-A-0 res: 2560x1440 dpi: 109 size: 597x335mm (23.5x13.2") diag: 685mm (27") 
           OpenGL: renderer: Radeon RX 580 Series v: 4.6.13572 Core Profile Context compat-v: 4.6.13572 direct render: Yes 
Audio:     Device-1: AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] vendor: Sapphire Limited driver: snd_hda_intel 
           v: kernel bus ID: 0a:00.1 chip ID: 1002:aaf0 
           Device-2: Advanced Micro Devices [AMD] Family 17h HD Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel 
           bus ID: 0c:00.3 chip ID: 1022:1457 
           Sound Server: ALSA v: k5.4.58-1-MANJARO 
Network:   Device-1: Intel Wireless-AC 9260 driver: iwlwifi v: kernel bus ID: 04:00.0 chip ID: 8086:2526 
           IF: wlp4s0 state: down mac: <filter> 
           Device-2: Intel 82580 Gigabit Network driver: igb v: 5.6.0-k port: N/A bus ID: 05:00.0 chip ID: 8086:150e 
           IF: enp5s0f0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
           Device-3: Intel 82580 Gigabit Network driver: igb v: 5.6.0-k port: N/A bus ID: 05:00.1 chip ID: 8086:150e 
           IF: enp5s0f1 state: up speed: 1000 Mbps duplex: full mac: <filter> 
           Device-4: Intel 82580 Gigabit Network driver: igb v: 5.6.0-k port: N/A bus ID: 05:00.2 chip ID: 8086:150e 
           IF: enp5s0f2 state: down mac: <filter> 
           Device-5: Intel 82580 Gigabit Network driver: igb v: 5.6.0-k port: N/A bus ID: 05:00.3 chip ID: 8086:150e 
           IF: enp5s0f3 state: down mac: <filter> 
           Device-6: Intel I211 Gigabit Network vendor: ASUSTeK driver: igb v: 5.6.0-k port: e000 bus ID: 06:00.0 
           chip ID: 8086:1539 
           IF: enp6s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
           IP v4: <filter> type: dynamic noprefixroute scope: global broadcast: <filter> 
           IP v6: <filter> type: noprefixroute scope: link 
           IF-ID-1: macvtap0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
           IF-ID-2: macvtap1 state: up speed: 1000 Mbps duplex: full mac: <filter> 
           WAN IP: <filter> 
Drives:    Local Storage: total: 3.24 TiB used: 748.94 GiB (22.6%) 
           SMART Message: Required tool smartctl not installed. Check --recommends 
           ID-1: /dev/nvme0n1 vendor: Western Digital model: WDS500G3X0C-00SJG0 size: 465.76 GiB block size: physical: 512 B 
           logical: 512 B speed: 31.6 Gb/s lanes: 4 serial: <filter> rev: 102000WD scheme: GPT 
           ID-2: /dev/sda vendor: Crucial model: CT1000MX500SSD1 size: 931.51 GiB block size: physical: 4096 B logical: 512 B 
           speed: 6.0 Gb/s serial: <filter> rev: 023 scheme: GPT 
           ID-3: /dev/sdb vendor: Crucial model: CT1000MX500SSD1 size: 931.51 GiB block size: physical: 4096 B logical: 512 B 
           speed: 6.0 Gb/s serial: <filter> rev: 023 scheme: GPT 
           ID-4: /dev/sdc vendor: Crucial model: CT1000MX500SSD1 size: 931.51 GiB block size: physical: 4096 B logical: 512 B 
           speed: 6.0 Gb/s serial: <filter> rev: 023 scheme: GPT 
           ID-5: /dev/sdd type: USB model: Multiple Card Reader size: 59.66 GiB block size: physical: 512 B logical: 512 B 
           serial: <filter> rev: 1.00 scheme: GPT 
           Message: No Optical or Floppy data was found. 
RAID:      Device-1: datastore type: zfs status: ONLINE size: 2.72 TiB free: 1.71 TiB allocated: 1.01 TiB Components: 
           online: N/A 
Partition: ID-1: / raw size: 396.40 GiB size: 389.18 GiB (98.18%) used: 142.19 GiB (36.5%) fs: ext4 block size: 4096 B 
           dev: /dev/nvme0n1p2 label: N/A uuid: 0b7011d2-bf5d-4d60-9441-083b80f54009 
           ID-2: /boot/efi raw size: 300.0 MiB size: 299.4 MiB (99.80%) used: 296 KiB (0.1%) fs: vfat block size: 512 B 
           dev: /dev/nvme0n1p1 label: N/A uuid: 95CE-1C09 
           ID-3: /mnt/data raw size: N/A size: 1.08 TiB used: 256 KiB (0.0%) fs: zfs raid: datastore label: N/A uuid: N/A 
           ID-4: /mnt/data/db raw size: N/A size: 1.08 TiB used: 6.6 MiB (0.0%) fs: zfs raid: datastore/db label: N/A 
           uuid: N/A 
           ID-5: /mnt/data/game raw size: N/A size: 1.45 TiB used: 382.56 GiB (25.8%) fs: zfs raid: datastore/game label: N/A 
           uuid: N/A 
           ID-6: /mnt/data/iso raw size: N/A size: 1.09 TiB used: 9.88 GiB (0.9%) fs: zfs raid: datastore/iso label: N/A 
           uuid: N/A 
           ID-7: /mnt/data/media raw size: N/A size: 1.15 TiB used: 75.65 GiB (6.4%) fs: zfs raid: datastore/media label: N/A 
           uuid: N/A 
           ID-8: /mnt/data/vms raw size: N/A size: 1.08 TiB used: 152 KiB (0.0%) fs: zfs raid: datastore/vms label: N/A 
           uuid: N/A 
           ID-9: /mnt/data/vms/android_e7 raw size: N/A size: 1.10 TiB used: 21.58 GiB (1.9%) fs: zfs 
           raid: datastore/vms/android_e7 label: N/A uuid: N/A 
           ID-10: /mnt/data/vms/lubuntu raw size: N/A size: 1.09 TiB used: 13.96 GiB (1.3%) fs: zfs 
           raid: datastore/vms/lubuntu label: N/A uuid: N/A 
           ID-11: /mnt/data/vms/win10_work_data raw size: N/A size: 1.09 TiB used: 13.58 GiB (1.2%) fs: zfs 
           raid: datastore/vms/win10_work_data label: N/A uuid: N/A 
           ID-12: /mnt/data/vms/win10_work_os raw size: N/A size: 1.16 TiB used: 89.53 GiB (7.5%) fs: zfs 
           raid: datastore/vms/win10_work_os label: N/A uuid: N/A 
           ID-13: /run/timeshift/backup raw size: 396.40 GiB size: N/A (hidden?) used: N/A (hidden?) fs: ext4 
           dev: /dev/nvme0n1p2 label: N/A uuid: 0b7011d2-bf5d-4d60-9441-083b80f54009 
Swap:      Kernel: swappiness: 60 (default) cache pressure: 100 (default) 
           ID-1: swap-1 type: partition size: 69.06 GiB used: 2.2 MiB (0.0%) priority: -2 dev: /dev/nvme0n1p3 label: N/A 
           uuid: d6bd5c20-26db-4bfa-9fe4-2de3cd57abbc 
Unmounted: ID-1: /dev/sda1 size: 931.50 GiB fs: zfs_member label: datastore uuid: 9508940478210377487 
           ID-2: /dev/sda9 size: 8.0 MiB fs: N/A label: N/A uuid: N/A 
           ID-3: /dev/sdb1 size: 931.50 GiB fs: zfs_member label: datastore uuid: 9508940478210377487 
           ID-4: /dev/sdb9 size: 8.0 MiB fs: N/A label: N/A uuid: N/A 
           ID-5: /dev/sdc1 size: 931.50 GiB fs: zfs_member label: datastore uuid: 9508940478210377487 
           ID-6: /dev/sdc9 size: 8.0 MiB fs: N/A label: N/A uuid: N/A 
           ID-7: /dev/sdd1 size: 16.0 MiB fs: exfat label: SD_64 uuid: DE68-7836 
           ID-8: /dev/sdd2 size: 59.64 GiB fs: N/A label: N/A uuid: N/A 
USB:       Hub: 1-0:1 info: Full speed (or root) Hub ports: 14 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 
           Hub: 1-4:20 info: Terminus Hub ports: 4 rev: 2.0 speed: 480 Mb/s chip ID: 1a40:0101 
           Device-1: 1-4.4:21 info: Alcor Micro Multi Flash Reader type: Mass Storage driver: usb-storage interfaces: 1 
           rev: 2.0 speed: 480 Mb/s chip ID: 058f:6366 serial: <filter> 
           Device-2: 1-5:2 info: Cyber Power System CP1500 AVR UPS type: HID driver: hid-generic,usbhid interfaces: 1 rev: 2.0 
           speed: 12 Mb/s chip ID: 0764:0501 serial: <filter> 
           Hub: 1-6:3 info: Logitech G11/G15 Keyboard / USB Hub ports: 4 rev: 1.1 speed: 12 Mb/s chip ID: 046d:c223 
           Device-1: 1-6.1:5 info: Logitech G15 Refresh Keyboard type: Keyboard,HID driver: hid-generic,usbhid interfaces: 2 
           rev: 2.0 speed: 1.5 Mb/s chip ID: 046d:c226 
           Device-2: 1-6.4:7 info: Logitech G15 Refresh Keyboard type: HID driver: usbfs interfaces: 1 rev: 2.0 speed: 12 Mb/s 
           chip ID: 046d:c227 
           Device-3: 1-9:4 info: ASUSTek AURA LED Controller type: HID driver: hid-generic,usbhid interfaces: 1 rev: 2.0 
           speed: 12 Mb/s chip ID: 0b05:1872 serial: <filter> 
           Device-4: 1-14:6 info: Cooler Master H500M type: HID,Keyboard driver: hid-generic,usbhid interfaces: 2 rev: 2.0 
           speed: 12 Mb/s chip ID: 2516:1001 serial: <filter> 
           Hub: 2-0:1 info: Full speed (or root) Hub ports: 8 rev: 3.1 speed: 10 Gb/s chip ID: 1d6b:0003 
           Hub: 3-0:1 info: Full speed (or root) Hub ports: 2 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 
           Hub: 4-0:1 info: Full speed (or root) Hub ports: 2 rev: 3.1 speed: 10 Gb/s chip ID: 1d6b:0003 
           Hub: 5-0:1 info: Full speed (or root) Hub ports: 4 rev: 2.0 speed: 480 Mb/s chip ID: 1d6b:0002 
           Device-1: 5-4:2 info: Elecom M-HT1URBK HUGE Optical TrackBall type: Mouse driver: elecom,usbhid interfaces: 1 
           rev: 2.0 speed: 12 Mb/s chip ID: 056e:010c 
           Hub: 6-0:1 info: Full speed (or root) Hub ports: 4 rev: 3.0 speed: 5 Gb/s chip ID: 1d6b:0003 
Sensors:   System Temperatures: cpu: 36.1 C mobo: N/A gpu: amdgpu temp: 31 C 
           Fan Speeds (RPM): N/A gpu: amdgpu fan: 785 
Info:      Processes: 525 Uptime: 6d 48m Init: systemd v: 245 Compilers: gcc: 10.1.0 clang: 10.0.1 Packages: pacman: 1461 
           lib: 412 flatpak: 0 Shell: Bash (sudo) v: 5.0.18 running in: yakuake inxi: 3.1.05 

Do you guys think this will be possible? If so, how would you suggest I go about it?

Thank you for reading and for your time today!

This smells of an SD card going bad, so the only other thing you can do is:

sudo smartctl --all /dev/sdd

and see if it’s about to fail (or not)

There is a way of installing JFFS2 as a file system under a Linux distro, but I’ve never done that, so look for “arch AND JFFS2” but you’re on your own there…

Remember: Android uses the Linux kernel, but it’s not a GNU/Linux distro!

:man_shrugging:

@Fabby I know this is a little late, but I want to thank you for pointing me in the direction of JFFS2. I didn’t end up using it, but while looking at the Arch wiki I came across something else. I was able to get mtpfs working and grab my files off the old SD card. I agree with you that it’s probably failing, so I replaced it. Naturally, now the same tool won’t work for the new card, but that is a problem for another day. 🤦

1 Like

I’ve marked the below answer as the solution to your question as it is by far the best answer you’ll get.

However, if you disagree with my choice, please feel free to take any other answer as the solution to your question or even remove the solution altogether: You are in control! (I just want to avoid even more subjective opinions being posted and confusing you even more)

:innocent:
P.S. In the future, please don’t forget to come back and click the 3 dots below the answer to mark a solution like this below the answer that helped you most:
Solution
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the “solved” status.