[SOLVED] Broken BFS journal

After a crash with PANIC: no space in log after sync which I obviously should not have continued, my boot volume is mounted read-only. Trying from a different system, this appears in the syslog:

KERN: bfs: Replay log, disk was not correctly unmounted...
KERN: run count: 1002310361, array max: 98, max runs: 126
KERN: bfs: KERN: Log entry has broken header!
KERN: bfs: KERN: replaying log entry from 2144 failed: Bad data
KERN: bfs: KERN: Replaying log failed, data may be corrupted, volume read-only.

That run count happens to be INODE_MAGIC1. checkfs doesn’t find any issue. Is there anything I can do to fix the volume even if I lose some files or the latest changes? I would much rather flip a few bits with an hex editor than reinstall.

You might play around with the BFS journal code and mount the partition with bfs_shell, to try and hack around the errors and mount read-write anyway?

The safest way is to copy all your files to another disk or partition, freshly formatted.

I expected someone would come with a reassuring answer like “check offset foo, if it is 42 and you don’t mind the risk, set it to 96, cross your fingers and reboot, you should only lose some metadata or latest changes” or whatever that would give some certainty that there wouldn’t be fs corruption.

Well, that’s life. I can always wipe it, reformat and restore from backup. Just for fun, I went with the bfs tools. When I got to the point I decided to change, I saw the code would just update the log start pointer and set the flags to a clean mount. I went with that. Interesting times ahead.

If your system boots, probably all you have to do now is run checkfs to reclaim the missing disk space.

1 Like

Yep, I did that. Discard journal log, mount, touch, unmount, mount, checkfs. Nothing in syslog, checkfs freed a few hundred blocks. Boots fine and no problem detected so far. I’m waiting for it.

Thank you for the pointer; I should have thought of bfs_shell & co. myself.

1 Like