Aargh! Overwrote busybox! How to modify overlay without mounting it as rootfs?

As the subject says, I managed to overwrite the busybox program on my OpenWrt 21.02.2 device. I'm able to boot into recovery mode, but running mount_root makes the system unusable.

I need a way to modify the overlay filesystem without mounting it as the root filesystem, so that I can restore the correct busybox executable.

Can anyone think of a way to do this?

Thanks!

Solved!

In failsafe mode, identify the root_data device:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00010000 "u-boot"
mtd1: 00fd0000 00010000 "firmware"
mtd2: 001f46b5 00010000 "kernel"
mtd3: 00ddb948 00010000 "rootfs"
mtd4: 00a60000 00010000 "rootfs_data"
mtd5: 00010000 00010000 "art"

Make a directory for it, and mount it.

# mkdir /tmp/root_data
# mount -t jffs2 /dev/mtdblock4 /tmp/root_data

I just needed to restore busybox to the version included in OpenWrt, so all I had to do was remove the "overlay" version.

# rm /tmp/root_data/upper/bin/busybox

With that done, I was able to unmount the root_data device, run mount_root to confirm that things were back to normal, and reboot.

# umount /tmp/root_data
# mount_root
<Check things out>
# reboot

Huzzah!

3 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.