OpenWrt Failsafe Üzemmód
OpenWrt has a built-in failsafe mode which will attempt to bypass almost all configuration in favor of a few hard coded defaults, resulting in a router that boots up as 192.168.1.1/24
with only essential services running. From this state you can telnet
in and fix certain problems.
Reading flash.layout, you should understand, that the OpenWrt failsafe can help you with any problems referring to the JFFS2 partition if you have a SquashFS image installed! In case you forgot your password or you firewall-ed yourself or you broke one of the startup scripts, you can get back in by using OpenWrt's failsafe mode.
Prerequisites
- your device must have a configurable hardware button, if there's a button on your router, it's likely to be configurable; check if there's specific info about failsafe mode for your box and make sure everything still works as expected everytime you update!
- alternatively you require a possibility to connect to console via the serial interface on the PCB
- anything but the JFFS2 partition, i.e. the kernel and the SquashFS partition must be intact, so that
- the boot process is able to get as far, as to register the pressing of the button
- the minimal required binaries and the configuration files with some default settings are available (all on SquashFS)
Triggering via Hardware Button (Standard OpenWrt method)
- Set your computer's IP to 192.168.1.2, subnet 255.255.255.0
- Power cycle the router (turn off and turn on)
- Immediately after the above step, rapidly click a button on the router for 60 seconds (it may be any button). Note: If your router has a ridiculously long boot time (such as DIR-300 A), then you may do this for a longer time.
- If done right, 192.168.1.1 will be pingable, and telnettable.
- Telnet into 192.168.1.1 -- there will be an immediate unauthenticated login to a root shell
- Try out the commands below
Triggering via keyboard key combination in a serial console
- Unplug the router's power cord.
- Connect the router's LAN1 port directly to your PC.
- Configure your PC with a static IP address between 192.168.1.2 and 192.168.1.254. E. g. 192.168.1.2 (gateway and DNS is not required).
- Plugin the power.
- Connect via serial
- Wait until the following messages is passing: Press the [f] key and hit [enter] to enter failsafe mode
- Press “f” and the “enter” key
- You should be able to telnet to the router at 192.168.1.1 now (no username and password)
In failsafe mode
You get a message like this “bla bla, you booted into failsafe mode”
NOTE: The root file system in failsafe mode is the only the SquashFS partition. The JFFS2 is not present. To mount JFFS2 in read-write mode run mount_root
:
mount_root
and then repair your system:
- In case you forgot your password, you need to set a new one. Type:
passwd
- In case you forgot the routers IP address, get it with
uci get network.lan.ipaddr
- In case you filled up the entire JFFS2 by installing too big/too many packages, clean the entire JFFS2 partition. All settings will be reset (OpenWrt equivalent of a factory reset)
mtd -r erase rootfs_data
If you are done with failsafe mode use
reboot -f
to reboot. (Normal /sbin/reboot
will not work, because init
is not running.) Or power cycle the router.
Notes
- the article process.boot may help you better understand when
failsafe
“kicks in” once activated