Corrupt SD after reboot? Wondering how to retrieve files

So after I hit “reboot” from the HA front-end, my rpi won’t boot anymore. It’s showing errors like “Card stuck in wrong state” and “lost async page write”. From reading on these forums I get the feeling that the SD card is corrupted (only been using HA for about a month). So, I inserted the SD card in my (Windows) laptop and using DiskInternals Linux Reader I wanted to retrieve my backup snapshots and/or config files.
However, I can’t find them. I have a lot of volumes:
image
Most of them are empty or have only an (empty) lost + found directory. Where can I find my files?

If you don’t have a spare linux computer, boot your pc with a linux live usb and run fsck

Thanks for the reply. I booted Ubuntu from a USB drive, and tried running fsck. fsck -A is done immediately, doesn’t seem to do anything.

However, using df -h to check all mounted drives shows that it doesn’t seem to recognise the sd card at all. Which is weird because Ubuntu does play a sound when I insert or eject the drive. Any ideas?

run without the sd card inserted

sudo fdisk -l (it's a lower case L)

then insert your sd card
and run

sudo fdisk -l

again.

See if there are any extra devices visible. If there are, run

sudo fsck -y  /dev/mmcblk0p1

on each devices that appeared (replace /dev/mmcblk0p1 with the actual devices)

I did get an additional Disk with a few Devices. Firstly:

sudo fsck -y /dev/mmcblk0p1

fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
fsck.ext2: No such file or directory while trying to open /dev/mmcblk0p1
Possibly non-existent device?

Looks like I needed to select the Disk not the Device, so I then tried:

sudo fsck -y /dev/mmcblk0 
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-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/mmcblk0

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a gpt partition table in /dev/mmcblk0

Looks like a classic case of, I’m screwed? :sweat_smile:

Edit: I did get some more results when trying the other devices than just /dev/mmcblk0p1. There are 8 in total, of which one states “non-existent device”, two return this:

fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
hassos-kernel: clean, 12/6144 files, 24151/24576 blocks

And the other five return:

fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
fsck.ext2: Input/output error while trying to open /dev/mmcblk0p6

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Bad news, if your superblock is corrupted, you may forget about recovering the contents of these partitions. I never managed to repair anything with a corrupted superblock.

Alright, I guess the first thing I’ll set up will be remote backups on my re-install… thanks for your time anyway!

I had the same thing happen after just a week of playing with HA and some camera recording automations. I was using a cheap “Onn” brand microSD card in my RPi4 and it got corrupted and went into read-only mode.

After that (and then reading a lot of similar corruption horror stories on Raspberry Pi and HA forums), I decided to switch to “Samsung PRO Endurance” microSD cards.