UBIFS recovery on Plug

After the UBIFS was corrupted due to power glitch pluggy the plug computer wouldn’t boot, giving console messages

UBIFS: recovery needed
Error reading superblock on volume 'ubi:rootfs'!
UBIFS not mounted, use ubifs mount to mount volume first!
UBIFS not mounted, use ubifs mount to mount volume first!
Wrong Image Format for bootm command
ERROR: can't get kernel image!

Apparently this is a known problem with some versions of UBIFS (1, 2, 3).

To recover the UBIFS, boot plug from USB then

$ sudo su
$ mkdir /tmp/ubifs 
$ ubiattach /dev/ubi_ctrl -m 2 
$ mount -t ubifs ubi0:rootfs /tmp/ubifs
$ umount /tmp/ubifs

All being well, on mounting get messages to effect that recovery is needed, and then completed.

Lessons learnt: 1. if plug hangs while doing something, pulling the power isn’t a good recovery optiion 😉 2. It’s useful to have some alternative boot media on hand, and probably worth  investing a little time to set up u-boot commands for these media.