1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

[FAQ] NVRAM and Factory Default Reset

Discussion in 'ASUS Wireless' started by RMerlin, Feb 15, 2015.

Thread Status:
Not open for further replies.
  1. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    28,560
    Location:
    Canada
    A lot of questions related to nvram keep popping up on the forums, usually always the same coming back again and again. This post is an attempt to at least clear up a lot of recurring questions.


    What is nvram?
    NVRAM stands for Non-Volatile Random Access Memory. It's a small portion of the router's flash memory that's usually between 32 KB and 128 KB in size (depending on the router model), and which contains all the router settings. This includes both some low-level settings that are automatically managed by the router (such as power gain per antenna, GPIO addresses of hardware features, etc...), temporary storage, and user-configured settings.


    Default settings - where do they come from?
    The first time a router boots, it will start by copying various default settings from the bootloader (or CFE in the case of Broadcom's routers). Once it starts booting the firmware itself, another set of default settings are taken from the firmware, and written back to nvram. This is why in certain cases it's very important that you do a factory default reset (more on this below).


    What happens if I run out of nvram space?
    Best case scenario: your router simply stops storing any settings change you make. Worst case scenario: the nvram content gets corrupted, router crashes, and you are forced to do a factory default reset, and start all over from scratch to be able to once again boot the router.


    Why do I sometime need to do a factory default reset?
    In addition to those user-entered settings, there's all those system level settings I previously mentioned. Sometimes, the manufacturer will need to change some of those low-level settings, either to resolve an issue, or to adapt to a newer wireless driver that they started using.

    If you fail to do a factory default reset, then your router will still have the old values, and it will keep using them. That can lead to performance issues (especially in changes related to the wireless driver), or flat out odd behaviour (if one of the settings no longer works the same way as before).


    Can I just restore my saved settings after I do a factory default reset?
    No. The idea behind a factory default reset is to have your router start using the NEW default values. If you restore your saved settings, you will overwrite those new values with the old ones, and you are back to square one.

    This is similar to having a PC with a corrupted Windows installation. If you reformat, and immediately after you restore a Ghost/TrueImage/Clonezilla backup on top of the reformatted Windows, you are back to where you were before you did all that work.


    Factory default reset: before, or after flashing?
    Since the goal is to use the NEW default values that are included in the NEW firmware, the factory default reset must be done while the NEW firmware is already flashed. Doing so before flashing will leave you running the OLD default values.


    How do I do a factory default reset?
    Multiple ways to do so, which will depend on your particular situation.

    If your router fails to boot due to corrupted/invalid nvram settings, then you will have to turn off the router, press the WPS button (on Asus routers), then turn on the router. Wait about 10 seconds, then release the WPS button.

    If the router is booting correctly, then you can use any of the following:

    • While router is running, press the reset button for about 5 secs, then release it. Router will then reboot.
    • From the webui, on the same page where you can save/restore saved settings, there is a button to restore factory default values
    • Over SSH, you can run the "nvram erase" command.
    • Over SSH you can manually erase the nvram partition (do not use this method unless you know what you are doing! Erasing the wrong partition can permanently brick your router!) Run "mtd-erase nvram", followed by PHYSICALLY turning off then on the router. Do not use the reboot command.



    Any way to ease the pain of reconfiguring after a factory default reset?
    A few methods:

    • Note down the important settings, using screenshots, and then reconfigure the router using these screenshots as a reference.
    • Keep a text-based backup of all your settings, and manually restore the important settings over SSH/telnet.
    • Use a specialized tool such as John9527's tool, which is specifically designed to handle various scenarios.


    How to I use get a text-based backup?
    Connect to your router over SSH/telnet, and run the following:

    Code:
    nvram show | sort
    
    If you have a USB disk plugged as /mnt/sda1/, then you can save the output to a text file:

    Code:
    nvram show | sort > /mnt/sda1/settings.txt
    

    How do I restore a specific setting?
    If you noted down a particular setting (or have a complete text dump of them), the syntax would look like this example:

    Code:
    nvram set dhcp_staticlist="what is saved in your text file output"
    ... do all others nvram set here ...
    nvram commit
    

    When do I need to do a factory default reset?
    The first rule is to check the changelog of the firmware you are about to flash. If for a particular reason this specific firmware release requires one, it will be mentionned.

    Also, if jumping more than one revision, check the changelog of past release. If going from 376.40 to 376.45, and 376.43 required a factory default reset, then you must also do so with the 376.45 flash.

    As a general rule, if you are jumping more than 2-3 revisions, it's often safer to do a factory default reset. If you want to try out without doing a factory default reset, go ahead and try it. But at the first sign of problem, be prepared to do one.


    What are those saved config files for if I can't reuse them?
    Those are backups. They are still very useful for the following scenarios:

    • When trying to resolve an issue by making a lot of random changes, and you want to be able to revert back to your original setup
    • If a bug, corruption issue or a power surge caused your router to lose all of its configuration, you can restore it
    • Having 2 or more alternative configurations that you want to easily switch between (personally, almost all my routers have a _Development and _Production copy of my settings, based on whether the router is fronting my Internet connection, or sitting behind another router).
     
    Last edited: Feb 15, 2015
    kernol, spencnor1, Jerry12 and 54 others like this.
Thread Status:
Not open for further replies.