OpenWrt offers several ways to “start over” with your router.
OpenWrt allows you to boot into a failsafe mode that overrides its current configuration. If your device becomes inaccessible, e.g. after a configuration error, then failsafe mode is there to help you out. When you reboot in failsafe mode, the device starts up in a basic operating state, with a few hard coded defaults, and you can begin to fix the problem manually.
Failsafe mode cannot, however, fix more deeply rooted problems like faulty hardware or a broken kernel. It is similar to a reset, however with failsafe, you can to access your device and restore settings if desired, whereas a reset would just wipe everything.
Caveat: Failsafe mode is only available if you have installed firmware from a SquashFS image, that includes the required read-only root partition. To verify whether your device has the SquashFS root partition, check for “squashfs” either in the OpenWrt image name or perform the following check on your device:
grep squash /proc/mounts
The terminal should return something similar to this:
/dev/root /rom squashfs ro,relatime 0 0
Make sure you use a wired connection, since the failsafe will disable your wireless connectivity.
On most routers, OpenWrt will blink a LED (usually “Power”, may be other) during the boot process after it gets control from the initial bootloader (like u-boot). OpenWrt will rather early in the boot cycle check if the user wants to enter the failsafe mode instead of a normal boot. It listens for a button press inside a specific two second window, which is indicated with LEDs and by transmitting an UDP package.
To enter failsafe mode, follow one of the procedures listed below:
Recommended for most users: Wait for a flashing LED and press a button. This is usually the easiest method once you figure out the correct moment.
For most users and most devices, the LEDs now (2018) provide sufficient clues as to timing to be able to avoid older recommendations to “press the XXX button as fast as you can until …” for entering failsafe mode.
There are three different (power) LED blinking speeds during boot for most of the routers:
Alternate for expert users: Wait (with a packet sniffer) for a special broadcast packet and press a button. The packet will be sent to destination address 192.168.1.255 port UDP 4919. The packet contains the text “Please press button now to enter failsafe”. So for example, in a terminal and using tcpdump, with the router connected to port eth0, you would enter the command
tcpdump -Ani eth0 port 4919 and udp
Alternate for expert users with serial connection: Watch for a boot message on the serial console and press a key (“f”) on the serial keyboard. This requires that you have attached a serial cable to the device. The message shown in the console is “Press the [f] key and hit [enter] to enter failsafe mode”
Usually, it is easiest to watch the LEDs. However, do consult the available documentation for your device, as there is no default button assigned as a reset button and not all procedures work on every device. Whichever trigger you use, the device will enter failsafe mode and you can access the command line with SSH (always possible) or a serial keyboard.
Note that modern OpenWrt uses always SSH, but early OpenWrt releases (15.05 and before) offered a telnet connection in this state but no SSH.
Note: old OpenWrt wiki page offer more details, most of them still valid: https://wiki.openwrt.org/doc/howto/generic.failsafe
Once failsafe mode is triggered, the router will boot with a network address of 192.168.1.1/24, usually on the eth0 network interface, with only essential services running. Using SSH or a serial connection, you can then mount the JFFS2 partition with the following command:
After that, you can start looking around and fix what’s broken. The JFFS2 partition will be mounted to /overlay, as under normal operation.
A factory reset returns your router to the configuration it had just after flashing. This works on any install with a squashfs / overlayfs setup (the norm for most installations), since it is based on erasing and reformatting the overlayfs.
x86 builds (made for PC/Server hardware) with an ext4 read-write rootfs cannot be reset this way.
With a large NOR chip, it can take 3 to 5 minutes for the overlayfs to be formatted in the flash. During this time, changes cannot be saved.
On devices with a physical reset button, OpenWrt can be reset to default settings without serial or SSH access.
The device will do a Hard Factory Reset (see below) and then reboot. On some devices this operation can be slow, so wait a few minutes before connecting again.
If you want a clean slate, there’s no need to flash again; just enter the following commands. Your device's settings will be reset to defaults like when OpenWrt was first installed.
Issuing “firstboot” or “jffs2reset” command will attempt to delete all files from the jffs2 overlay partition. Note that this “soft reset” is performed with file system actions, so in some cases it is not enough.
firstboot && reboot now
Note: If the commands above (all on one line) don't work, try those commands on separate lines in the terminal.
Note: for most routers, “firstboot” actually just issues a “jffs2reset” command, so there is not much difference compared to the “hard reset” advice below.
This command will erase and reformat the whole jffs2 partition and create it again. They key for a real “hard reset” is to unmount the overlay partition first and only then issue the jffs2reset (or firstboot) command:
umount /overlay && jffs2reset && reboot now
While in most cases this is producing similar end-result as the “soft reset”, this marks the whole flash area of the JFFS2 (read-write) overlay partition as a empty non-initialised jffs2 partition. Thus the partition will be re-created at the next mount, usually at the next boot. So, this hard reset bypasses the current file system of the overlay.
Explanation: based on the mount status of the overlay, jffs2reset selects either a file-based delete operation or a partition mark-it-empty action: https://git.openwrt.org/?p=project/fstools.git;a=blob;f=jffs2reset.c;h=dbe049881f5;hb=HEAD#l43
It's possible to edit and transfer files from the Failsafe mode, by using scp command/protocol from Linux or Mac, or by using WinSCP from Windows.
If you transfer over a sysupgrade image, you can also do a commandline sysupgrade ( syupgrade -n /path/to/file ) as normal.
If neither Failsafe Mode nor Factory Reset returns control of your router, you can often replace the firmware of your device using one of the procedures described on the Recovery Mode page.