Recover from read-only with system running

Hi there,
I'm trying to recover a openwrt router remotely where the filesystem is full.

Context:
I will have routers on clients that are lay and besides this there is no console.
I'm writing a script that runs at boot (/etc/rc.local) to test if there are problems with a router.
The firts test is to find out if the overlay mounted correctly.
If it mounted read-only (probably fith disk full), I want to erase some files and reboot.
How can I do that?

Best
carliedu

Files that are in the default image are not removed; and marking them as deleted can actually use more file space.

To save more space in a default image, you would have to compile a smaller custom firmware.

Hi,
I found the solution.

I added the following lines to /etc/rc.local

----------------------------------------------------------------------------------------

Root_Mounted=$(mount | grep "overlayfs:/overlay" | grep "rw")
if [ -z "$Root_Mounted" ]
then
echo "It's in read-only mode"
mount_root
rm /overlay/work/*
reboot
else
logger "Normal Boot"
fi

----------------------------------------------------------------------------------------

This works fine.

Best,
carliedu

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