nvram usage question

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2, 3  Next
Author Message
lesf
DD-WRT Novice


Joined: 02 Nov 2008
Posts: 12
Location: Davidsonville, Md

PostPosted: Sun Nov 30, 2008 15:07    Post subject: nvram usage question Reply with quote
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?
Sponsor
Donny
DD-WRT Guru


Joined: 13 Nov 2008
Posts: 5266
Location: CENTRAL Midnowhere

PostPosted: Sun Nov 30, 2008 15:20    Post subject: Reply with quote
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

Peacock Thread Sticky- Just read it! (Anyone using SP1 will be taken out back and shot)
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=51486
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Nov 30, 2008 16:05    Post subject: Reply with quote
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
Donny
DD-WRT Guru


Joined: 13 Nov 2008
Posts: 5266
Location: CENTRAL Midnowhere

PostPosted: Sun Nov 30, 2008 16:09    Post subject: Reply with quote
@frater:

Can you explain, basically, how the script works? Does it convert the txt to binary and write them directly to the nvram?

This is all I could find:

http://www.dd-wrt.com/phpBB2/viewtopic.php?t=33164&

_________________
Warning: I'm "out of my element!"
http://www.youtube.com/watch?v=MjYJ7zZ9BRw&NR=1

Peacock Thread Sticky- Just read it! (Anyone using SP1 will be taken out back and shot)
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=51486
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Nov 30, 2008 16:24    Post subject: Reply with quote
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=19556

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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Sun Nov 30, 2008 17:45    Post subject: Reply with quote
frater wrote:
The problem with restoring a backup from another version isn't about the values of these variables.


Test your theory. Do

nvram set http_passwd="clearTextPassword"
nvram commit

Back it up. Restore it, however you wish...binary mode or ascii..

I think you'll find that you've locked yourself out of the router.

My point being, the values of variables do make a difference...and Donny was spot on.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Nov 30, 2008 17:59    Post subject: Reply with quote
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Sun Nov 30, 2008 18:22    Post subject: Reply with quote
frater wrote:
You are reversing my reasoning.


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.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Nov 30, 2008 18:40    Post subject: Reply with quote
soulstace wrote:
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Sun Nov 30, 2008 18:50    Post subject: Reply with quote
frater wrote:
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.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Nov 30, 2008 19:09    Post subject: Reply with quote
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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
olmari
DD-WRT Guru


Joined: 24 Oct 2006
Posts: 1447
Location: Finland

PostPosted: Sun Nov 30, 2008 19:14    Post subject: Reply with quote
frater wrote:
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.
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Sun Nov 30, 2008 19:32    Post subject: Reply with quote
Thank you olmari.

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.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Nov 30, 2008 19:33    Post subject: Reply with quote
My point was:

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

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
olmari
DD-WRT Guru


Joined: 24 Oct 2006
Posts: 1447
Location: Finland

PostPosted: Sun Nov 30, 2008 19:39    Post subject: Reply with quote
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?
Goto page 1, 2, 3  Next Display posts from previous:    Page 1 of 3
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum