Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:troubleshooting:failsafe_and_factory_reset [2018/03/26 18:09] – [Failsafe Mode] touchy2018docs:guide-user:troubleshooting:failsafe_and_factory_reset [2024/06/23 11:45] – Tweak failsafe to remind about setting static IP for the PC richb-hanover
Line 1: Line 1:
-====== Failsafe ModeFactory Reset, and Recovery Mode ====== +====== Failsafe modefactory reset, and recovery mode ====== 
-OpenWrt offers several ways to "start over" with your router +OpenWrt offers several ways to "start over" with your router: 
-  * **Failsafe Mode** is useful if you have lost control of your device, and it has become inaccessible, perhaps through a configuration error. It allows you to reboot the router into a basic operating state, retaining all your packages and (most) settings. ([[#failsafe_mode|see Failsafe Mode]]+  * **[[docs:guide-user:troubleshooting:failsafe_and_factory_reset#failsafe_mode|Failsafe mode]]** is useful if you have lost control of your device, and it has become inaccessible, perhaps through a configuration error. It allows you to reboot the router into a basic operating state, retaining all your packages and (most) settings. 
-  * **Factory Reset** erases all your packages and settings, returning the router to its initial state after installing OpenWrt. ([[#factory_reset|see Factory Reset]]) +  * **[[docs:guide-user:troubleshooting:failsafe_and_factory_reset#factory_reset|Factory reset]]** erases all your packages and settings, returning the router to its initial state after installing OpenWrt. 
-  * **Recovery Mode** allows you to install new firmware on a router that has become corrupted. ([[#recovery_mode|see Recovery Mode]])+  * **[[docs:guide-user:troubleshooting:vendor_specific_rescue|Recovery mode]]** allows you to install new firmware on a router that has become corrupted.
  
-===== Failsafe Mode ===== +===== Failsafe mode ===== 
-//LEDE// 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. +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 kernelIt is similar to resethowever with failsafeyou can to access your device and restore settings if desired, whereas a reset would just wipe everything.+Failsafe mode can be triggered by pressing (almost any) button on the device shortly after powering it on. 
 +Each router is unique, but OpenWrt watches for WPSResetor other button press.
  
-**Caveat:** Failsafe mode is only available if you have installed firmware from SquashFS imagethat includes the required read-only root partition. To verify whether your device has the SquashFS root partitioncheck for "squashfs" either in the //LEDE// image name or perform the following check on your device:+Failsafe mode **cannot**, however, fix more deeply rooted problems like faulty hardware or a broken kernel. 
 +It is similar to resethowever with failsafeyou can access your device and restore settings if desired, whereas a reset would just wipe everything.
  
-<code>+**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: 
 + 
 +<code bash>
 grep squash /proc/mounts grep squash /proc/mounts
 </code> </code>
Line 18: Line 25:
 The terminal should return something similar to this: The terminal should return something similar to this:
  
-<code>/dev/root /rom squashfs ro,relatime 0 0</code>+<code> 
 +/dev/root /rom squashfs ro,relatime 0 0 
 +</code> 
 + 
 ==== Entering failsafe mode ==== ==== Entering failsafe mode ====
 +Failsafe mode starts the router with the IP address 192.168.1.1, and disables
 +DHCP and wireless connectivity.
 +You will need to set your PC to a static address on the same subnet
 +(e.g., 192.168.1.10) and connect via Ethernet.
 +Sometimes you need to connect to a specific network port of your router
 +to get connectivity.
 +**Try the LAN1 port first.**
 +DSA devices frequently enable [[https://forum.openwrt.org/t/adding-openwrt-support-for-xiaomi-ax3600/55049/9760|LAN1 only]].
  
-Make sure you use a wired connectionsince the failsafe will disable your wireless connectivity.+On most routersOpenWrt will blink an LED (usually "Power") during the boot process. 
 +Early in the boot cycle, OpenWrt watches for a button press (any button) 
 +inside a specific two second window to indicate that it should enter failsafe mode.
  
-On most routers, LEDE will blink a LED (usually "Power", may be other) during the boot process after it gets control from the initial bootloader (like u-boot). LEDE 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:**
  
-There are three different (power) LED blinking speeds during boot for most of the routers:+**Simplest - recommended for most peoplePower on the device, wait for a flashing LED and press a button.** 
 +This can be the WPS, Reset, or other button on the device.
  
-  * first a moderate 0.1 second blinking rhythm during those two seconds, when router waits for user to trigger the failsafe mode +The LEDs provide clues for timing the button press. 
-  * then either +Watch the LED blinking speeds immediately after powering up the router. 
-       * a slow 0.2 second blink continuing to the end of boot, if the failsafe was not triggered and the normal boot continues +Most routers show three different (power) LED blinking speeds during boot:
-       * a rapid 0.05 second blink if the user pressed a button and failsafe mode was triggered+
  
-**To enter failsafe mode, follow one of the procedures listed below:**+  A power-on sequence of lights that is specific to the device's bootloader 
 +  Then a fast 5-per-second blinking rhythm during two seconds, while router waits for a button press 
 +  * Then either: 
 +       * A faster, 10-per-second blink if failsafe mode was triggered. The device is listening on 192.168.1.1 
 +       * A slower2.5-per-second blink continuing to the end of normal boot, if the failsafe was not triggered 
 +  * If you missed the timing and see the slower blink rate, just power off the device, wait a couple seconds, and try again. 
 +   
 +**Alternate for expert usersWait (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 of your computer, you would enter the command <code>tcpdump -Ani eth0 port 4919 and udp</code>
  
-  * **Wait for a flashing LED and press a button.** This is usually the easiest method once you figure out the correct moment. +**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. 
-  * **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 <code>tcpdump -Ani eth0 port 4919 and udp</code> +The message shown in the console is "//Press the [f] key and hit [Enter] to enter failsafe mode//"
-  * **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.+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 LEDE uses always SSH, but early OpenWrt releases (15.05 and before) offered a telnet connection in this state but no SSH.+Note that modern OpenWrt always uses SSH for terminal connections. 
 + 
 + 
 +=================
  
-Note: old OpenWrt wiki page offer more details, most of them still valid: https://wiki.openwrt.org/doc/howto/generic.failsafe 
 ==== Fixing your settings ==== ==== Fixing your settings ====
 +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.
 +When in failsafe mode, the DHCP server will not be running.
 +You must set your computer's ethernet port to use a static IP address in the 192.168.1.0/24 network (valid IPs are 192.168.1.2 - 192.168.1.254, subnet mask 255.255.255.0)
  
-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:+Using SSH or a serial connection, you can then mount the JFFS2 partition with the following command:
  
-<code>+<code bash>
 mount_root mount_root
 </code> </code>
  
-After that, you can start looking around and fix what’s broken. The JFFS2 partition will be mounted to ///overlay//, as under normal operation.+After that, you can start looking around and fix what’s broken. 
 +The JFFS2 partition will be mounted to ''/overlay'', as under normal operation.
  
-===== Factory Reset ===== +You can also transfer files by using scp command/protocol from Linux or macOSor by using [[docs:guide-quick-start:sshadministration#winscp|WinSCP]] from Windows.
-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. //Note:// X86 builds 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. +Additional steps required for [[:docs:guide-user:additional-software:extroot_configuration|Extroot]] setups:
-==== Soft Factory Reset ==== +
-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 LEDE was first installed.+
  
-<code> +<code bash
-umount /overlay && firstboot && reboot+# unplug external device 
 +reboot 
 + 
 +# plug external device 
 +# mount external device, e.g. 
 +block info 
 +mount /dev/mmcblk0 /mnt 
 + 
 +# fix the issue, e.g. 
 +vi /mnt/upper/etc/config/network 
 + 
 +# verify external device will be mounted automatically, e.g. 
 +vi /overlay/upper/etc/config/fstab 
 +reboot
 </code> </code>
-Note: for most routers, "firstboot" actually just issues a "jffs2reset" command, so there is no difference compared to the "hard reset" advice below. 
  
-Note: If <code> +===== Factory reset ===== 
-umount /overlay && firstboot && reboot+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. 
 + 
 +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. 
 + 
 +**Caveat:** 
 +  * Factory reset depends on completing the boot process. If factory reset is not working, try with failsafe mode instead. 
 +  * x86 builds (made for PC/Server hardware) with an ext4 read-write rootfs cannot be reset this way. 
 + 
 +==== Reset button ==== 
 +On devices with a physical reset button, OpenWrt can be reset to default settings without serial or SSH access. 
 + 
 +  - Power on the device and wait for the status led to stop flashing (or go into failsafe mode, as described above). 
 +  - Press and hold the reset button for 10 seconds. 
 +  - Release the reset button. 
 + 
 +The device will do a hard factory reset (see below) and then reboot. 
 +This operation can be slow on some devices, so wait a few minutes before connecting again. 
 + 
 +==== Soft factory reset ==== 
 +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. 
 + 
 +<code bash
 +firstboot && reboot
 </code> </code>
-does not work, try those commands on separate lines in the terminal. 
-==== Hard Factory Reset ==== 
-This command will erase and reformat the whole jffs2 partition and create it again:  
  
-<code>+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. 
 + 
 +Note: if you're issuing this command inside a bash script, remember to add the option -y to force firstboot: 
 + 
 +<code bash> 
 +firstboot -y && reboot 
 +</code> 
 + 
 +Here is a log of soft factory reset process in action, obtained via serial connection, during router startup**:** 
 +  * <code>... 
 +Press the [f] key and hit [enter] to enter failsafe mode 
 +Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level 
 +
 +- failsafe - 
 +/etc/preinit: line 1: /sbin/mtk_failsafe.sh: not found 
 +/etc/preinit: line 1: dropbearkey: not found 
 +/etc/preinit: line 1: dropbear: not found 
 + 
 +BusyBox v1.25.1 () built-in shell (ash) 
 + 
 +ash: can't access tty; job control turned off 
 +     _________ 
 +    /        /\      _    ___ ___  ___ 
 +   /  LE    /  \    | |  | __|   \| __| 
 +  /    DE  /    \   | |__| _|| |) | _| 
 + /________/  LE  \  |____|___|___/|___|                      lede-project.org 
 +        \   DE / 
 +  \    LE  \    /  ----------------------------------------------------------- 
 +    DE    \  /    Reboot (17.01-SNAPSHOT, r0-e88ba24) 
 +    \________\/    ----------------------------------------------------------- 
 + 
 +================= FAILSAFE MODE active ================ 
 +special commands: 
 +* firstboot      reset settings to factory defaults 
 +* mount_root mount root-partition with config files 
 + 
 +after mount_root: 
 +* passwd change root's password 
 +* /etc/config     directory with config files 
 + 
 +for more help see: 
 +http://wiki.openwrt.org/doc/howto/generic.failsafe 
 +======================================================= 
 + 
 +admin@(none):/# firstboot && reboot 
 +[  102.942293] jffs2reset: This will erase all settings and remove any installed packages. Are you sure? [N/y] 
 +
 +[  117.606813] jffs2reset: /dev/mtdblock6 is not mounted 
 +[  117.612055] jffs2reset: /dev/mtdblock6 will be erased on next mount 
 +reboot 
 +admin@(none):/# [  119.810569] ===> rt_pci_shutdown() 
 +...</code> 
 + 
 +Tips**:** after (a OpenWrt based) router reboots or starts, it goes thru the bootmenu (selection menu for boot options) within 1 to 2 seconds (or, within 1 second, after preset delay time has passed). 
 +The boot menu accepts Up/Down & Enter buttons, so avoid those or any other buttons for that period of time. 
 +After that bootmenu stage, within 3 to 8 seconds later (depending on CPU speed, etc) the failsafe mode appears & passes, so you have to press the "f" button within that time only for once (one time), then press Enter to enter into failsafe mode. 
 + 
 +==== Hard factory reset ==== 
 +=== Re-flashing the firmware === 
 +Re-flash or upgrade the firmware discarding the settings. 
 + 
 +<code bash> 
 +sysupgrade -n /path/to/firmware 
 +</code> 
 + 
 +OpenWrt preserves settings [[docs:guide-quick-start:admingui_sysupgrade_keepsettings|by default]], so you need to opt-out to achieve factory reset. 
 + 
 +=== JFFS2 reset === 
 +Reset the JFFS2 partition. 
 + 
 +<code bash>
 umount /overlay && jffs2reset && reboot umount /overlay && jffs2reset && reboot
 </code> </code>
  
-While essentially doing the same thing as //firstboot//, this actually rewrites the whole flash area of the JFFS2 (read-write) partition instead of just re-formatting it.+Based on the mount status of the overlay, jffs2reset [[commit>?p=project/fstools.git;a=blob;f=jffs2reset.c;h=dbe049881f5;hb=HEAD#l43|selects]] either a file-based delete operation or a partition mark-it-empty action to be re-created at boot. 
 + 
 +=== F2FS reset === 
 +Reset the F2FS partition. 
 + 
 +<code bash> 
 +dd if=/dev/zero of=/dev/loop0 bs=1M; reboot 
 +</code>
  
-===== Recovery Mode ===== 
-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 [[docs/guide-user/troubleshooting/vendor_specific_rescue|Recovery Mode page.]] 
  • Last modified: 2024/12/07 10:49
  • by hnyman