OK, the issue was indeed a corrupted fileystem. The boot log gave:
[ 2.233367] EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesystem
[ 2.240887] EXT4-fs (mmcblk0p2): write access will be enabled during recovery
[ 2.292741] JBD2: Invalid checksum recovering block 0 in log
[ 4.408938] JBD2: recovery failed
[ 4.412393] EXT4-fs (mmcblk0p2): error loading journal
[ 4.419493] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2): error -5
When inserting the SD card in another machine and using fsck.ext4
, it gets fixed quickly:
root@revc:~# fsck.ext4 /dev/mmcblk0p2
e2fsck 1.43.4 (31-Jan-2017)
BELAROOTFS: recovering journal
JBD2: Invalid checksum recovering block 0 in log
Journal checksum error found in BELAROOTFS
BELAROOTFS contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (284001, counted=283995).
Fix<y>? yes
BELAROOTFS: ***** FILE SYSTEM WAS MODIFIED *****
BELAROOTFS: 89772/224896 files (0.1% non-contiguous), 614565/898560 blocks
I can now boot from it.
I am surprised that the check that is run during boot fails to fix the damaged journal, while running fsck explicitly manages to fix it.
The future
To avoid this sort of - rare - inconvenieces, one could set the filesystem to read-only by editing /etc/fstab
, appending ro
to the options for /dev/mmclk0p2
, e.g.:
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
also add this line there
tmpfs /var/lib/dhcp tmpfs nosuid,nodev 0 0
After rebooting, all writes to disk will fail and the filesystem will be much less likely to become corrupted. If you want to make the filesystem read-write again (e.g.: to update your patch), you will need to first manually remount it as rw:
mount /dev/mmcblk0p2 -o remount,rw /
and then edit /etc/fstab
again and remove ,ro
so that the line looks like this again:
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1