Joined: 02 Nov 2008 Posts: 12 Location: Davidsonville, Md
Posted: Sun Nov 30, 2008 15:07 Post subject: nvram usage question
Trying to understand variable usage and nvram.
If I take an off the shelf router and flash dd-wrt, don't the old variables from the factory load stay around as well? Likewise if I flash say tomato, and then flash dd-wrt, aren't the tomato variables still laying around in nvram as well?
If this is the case, is there any way to clean up nvram other than going in by hand and deleting things not related to dd-wrt? Is there a list of nvram variables used by dd-wrt?
Joined: 13 Nov 2008 Posts: 5266 Location: CENTRAL Midnowhere
Posted: Sun Nov 30, 2008 15:20 Post subject:
Hard reset clears the nvram and all variables written to it. After you install firmware, nvram is written to with new variables from kernal...that is what it is doing in the two minutes following upgrade, and why it is important to let it sit and do that.
This is kind of explained in the Peacock Thread Sticky.
Nvram backup will backup ALL variables in nvram, including corrupt or inconsistent ones, and although they will be cleared on hard reset, they will be rewritten and you will be back to square one if you reinstall the backup config...which is why you should never do this if you upgrade firmware or if you are having a problem. _________________ Warning: I'm "out of my element!"
http://www.youtube.com/watch?v=MjYJ7zZ9BRw&NR=1
The problem with restoring a backup from another version isn't about the values of these variables.
A new variable is seldom introduced.
It's the way these variables are restored and that's in a binary method. That's the reason I wrote a script that will write those variables to a txt-file which can be used to restore those variables. (look for it on this forum). I'm glad I never have to restore all these settings by hand and find out a week later I forgot a few....
If brainslayer or Eko took the time for it, this problem with binary backup and restore could be solved. It's one of the features most of us want but somehow don't ask.
If there was a command to find out the default value of an nvram-variable, I could improve my script a lot. It would only save the variables that have been changed and would therefore be even more flexible in use. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
it does a "nvram show" and writes a script that can be used to restore the variables. In my case the result is being ftp'd to my NAS each night.
At first glance it can be done easier like the scripts on the first posts in this thread, but I did it this way to become better results.. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
You are reversing my reasoning.
If you want to mess things up deliberately, it is quite easy to do so.
If variables change, it can become a problem. But that was not what I said or mean to say.
The MAIN problem is not those changed variables.
Even when no variables have changed (in reality they rarely ever change) you still cannot savely restore a binary backed up config. That was my main point.
If I have mini installed and install a mega-version (same SVN) it can reset all of a sudden to factory default after a while. This often happens after several changes in the config.
Doing an erase of the nvram variables and then restoring the variables with this script, your router is as stable as when you do a factory default and restoring all variables by hand.
BTW: I'will still not be locked out. My router has an SSH-public key and I don't need a password to get in. This SSH-key can even be default when I compile my own. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Precisely...because this is what restoring backups from previous versions does. Reverses reasoning.
I've even seen where the firmware had bugs that wrote the wrong values into nvram. If you backup and restore those values, you're just creating more problems.
I've even seen where the firmware had bugs that wrote the wrong values into nvram. If you backup and restore those values, you're just creating more problems.
Yes, this is what happens if you do a binary restore. They can get corrupt. They will not get corrupt if you use my method.
If your variables contain strange values, the damage already has been done. My config doesn't contain strange values and as long as I stick to my own procedure, this will stay that way.
I assume you tested my script and see what it does? _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Yes, this is what happens if you do a binary restore. They can get corrupt. They will not get corrupt if you use my method.
But I am not talking backup/restore. I am talking about the Apply Settings button. Some versions of dd-wrt that I have tested have written the wrong values to nvram when pressing Apply Settings. After experiencing such behavior I cannot recommend to restore any nvram backups.
It does not matter if you restore values in binary mode or ascii.. If the values are wrong when they were backed up, they will be restored wrong. Your script will not be able to tell the difference.
I'm sure this corruption was the result of leaving out an erase of the nvram partition.
First you erase the nvram partition and then all the values are correctly written using the script. NOT by its webinterface. No corruption will happen there.
> Your script will not be able to tell the difference.
Don't underestimate what creativity can do. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
I'm sure this corruption was the result of leaving out an erase of the nvram partition.
First you erase the nvram partition and then all the values are correctly written using the script. NOT by its webinterface. No corruption will happen there.
> Your script will not be able to tell the difference.
Don't underestimate what creativity can do.
But soulstaces point was that if old DD-WRT writes wrong value, you can't know if that is wrong value, thus you will restore same wrong value no matter how perfectly you can write variables to the new DD-WRT version..
Now I don't underestimate the work you have done, but still safest thing is allways to do settings manually after fresh installation.
frater,
I am not talking bad about your script. It is nice work.
I am only stating that your initial assessment was a little off. nvram values do indeed come into play when using backup/restore feature. It is not just the fact that backups are in binary format.
The webinterface writes incorrect values if the partition which holds your nvram was not erased.
If you configure a factory default router and do an erase of the partition every time after an upgrade (with a subsequent rewrite of the variables with my script), your variables will NOT contain corrupt values.
When the size of the firmware changes, the partion becomes corrupt because it gets partially overwritten.
If you erase this partition after the upgrade, you can restore the variables with this script.
If you continue to work after a firmware upgrade you can get corruption.
buy a router
put dd-wrt on it with factory default
configure your router
write variables with script
upgrade firmware
reboot
erase nvram partition
rewrite variables with script
reboot
You can do this last part over and over and your variables will not get corrupt. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
How can you know webgui doesn't write bogus settings because of some programming error in every version? What if some variable names changes as they do from time or some old variables gets unused and there is new ones introduced?