[Solved] How to recover from a emmc data corruption?

Hi,
– Error –
I had the Beaglebone running fine for two and a half years.
Then while issuing apt-get update, the file system turned read-only, and the update failed to end well.

– Analyze –
I issued journalctl -r and noticed the emmc had errors in the device layer, which caused the file system to turn read-only.

– Rent –
(This why I hate Ext4 and such old file systems. I wish we could move on to BTRFS.

– Solution –
So I powered off the beaglebone.
I dis-assembled it from its cape.
I connected a FTDI serial cable to it and a USB cable.

When it booted I saw:

U-Boot SPL 2015.07-rc3-00001-g2c9c20a (Jun 30 2015 - 09:02:07)

U-Boot 2015.07-rc3-00001-g2c9c20a (Jun 30 2015 - 09:02:07 -0500), Build: jenkins-github_Bootloader-Builder-173

Watchdog enabled
I2C: ready
DRAM: 512 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Using default environment


oading, please wait…
BEAGLEBONE contains a file system with errors, check forced.
BEAGLEBONE: Inodes that were part of a corrupted orphan linked list found.

BEAGLEBONE: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
fsck exited with status code 4
The root filesystem on /dev/mmcblk1p1 requires a manual fsck
modprobe: module i8042 not found in modules.dep
modprobe: module ehci-pci not found in modules.dep
modprobe: module ehci-orion not found in modules.dep
modprobe: module uhci-hcd not found in modules.dep
modprobe: module ohci-hcd not found in modules.dep

BusyBox v1.22.1 (Debian 1:1.22.0-9+deb8u1) built-in shell (ash)
Enter ‘help’ for a list of built-in commands.

/bin/sh: can’t access tty; job control turned off
(initramfs)

To fix I ran:

(initramfs) fsck /dev/mmcblk1p1

fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
BEAGLEBONE contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found. Fix? yes
Inode 1546 was part of the orphaned inode list. FIXED.
Inode 1987 was part of the orphaned inode list. FIXED.
Inode 2030 was part of the orphaned inode list. FIXED.
Inode 2368 was part of the orphaned inode list. FIXED.
Inode 3705 was part of the orphaned inode list. FIXED.
Inode 4250 was part of the orphaned inode list. FIXED.
Inode 4631 was part of the orphaned inode list. FIXED.
Inode 5592 was part of the orphaned inode list. FIXED.
Inode 5700 was part of the orphaned inode list. FIXED.
Deleted inode 5798 has zero dtime. Fix? yes
Inode 6022 was part of the orphaned inode list. FIXED.
Inode 32774 was part of the orphaned inode list. FIXED.
Inode 69992 was part of the orphaned inode list. FIXED.
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -17865 -(51892–51894) -258249 -(258252–258254) -(268977–269121) -(404932–404971) -(626553–626600) -(659072–659186) -(766034–766160)
Fix? yes
BEAGLEBONE: ***** FILE SYSTEM WAS MODIFIED *****
BEAGLEBONE: 132374/236176 files (0.1% non-contiguous), 548166/943872 blocks
(initramfs) fsck /dev/mmcblk1p1
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
BEAGLEBONE: clean, 132374/236176 files, 548166/943872 blocks

Then type exit and
and the device booted as before.