Deleting NVRAM keys with no values

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 57

PostPosted: Sun Jun 16, 2024 9:48    Post subject: Deleting NVRAM keys with no values Reply with quote
This is a general question. I'm looking into something I started a few years back where I was going to attempt to use nvram dumps as a starting point for restoring certain settings after an upgrade in an effort to make it more reliable than restoring a saved backup file. There are a few settings which are very cumbersome to go back and reconfigure through the UI and could safely be restored from the command line like Port Forwards, static IPs, etc.

I already have a script that will parse the nvram dump and sort the keys and output a file that could be essentially run as a shell script to restore everything, but that's not what I want exactly. I want to be able to exclude a lot of keys that aren't absolutely required to get the system back up and running again.

My question right now is if there are keys that have a completely empty value (zero length), is it safe to unset those and remove them from the nvram completely?

Will the firmware recreate missing keys that it requires if something gets deleted that shouldn't have been?

I'm just asking now as I formulate the scope and plan of attack on this project.
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 13092
Location: Netherlands

PostPosted: Sun Jun 16, 2024 10:48    Post subject: Reply with quote
Have a look at easyddup: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=322503

But of course the firmware has default values, that is what is used if you reset to defaults.

IF you delete values then the value is gone sometimes it will use a default value sometimes not.

So what you should do is reset to defaults and then restore only the settings you want

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6519
Location: UK, London, just across the river..

PostPosted: Sun Jun 16, 2024 10:54    Post subject: Reply with quote
Hmm that is a good question...
I used to do that in the past, run a script to check and clear/unset the unused nvram variables..
i wont hurt, as BS the main Dev very often disable enable those when he is trying something and yes some are completely abandoned and not used for a long time until generally removed...or reused for some reason..

And yes new firmware will have those that ware deleted or reused so, in general it must be save to delete those...but...i stopped to do that as dont find need for it and not really helping unless you are very screwed on nvram size needs and ect...
Best practice is reset after on update...and redo settings manually..

There are also other things that are left over and ect. like nvram gremlins and
old hardware interfaces that you create and don't use or bridges and so on...be extra careful when you remove/unsed hardware interfaces...make sure to not unset a interface that is in use or exists and must be there...

That's all i know and in general dont fiddle with nvram variables that i dont know or are in use somehow...also i don't know if those scripts may clear some variables by mistake if they contain space/intervals at the begging and ect...or they don't have values until you start a particular service and ect...so there are pros and cons
Let see if someone else will chime in Razz

p.s. gees im such a slow type, when is a lunch time egc got me again Laughing

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 57200 WAP
TP-Link WR1043NDv2 -DD-WRT 56941 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 57200 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 57200 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 57200 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 57

PostPosted: Sun Jun 16, 2024 20:39    Post subject: Reply with quote
Thanks for your responses. I'm definitely going to be careful about it. I did a dump of the freshly installed version that I'm using now before I restored my settings and ran it through my script, then did the same after restoring my last backup and I can easily diff those two files, so that helps to see what was there on a clean load and what's extra in my restored settings. I can see there are cases where you turn on a setting just to play around, then turn it back off and it created a bunch of nvram settings in the process. There are some that probably go back to the beginning of using this router and are no longer relevant.

It's already helpful for restoring long items that take forever in the UI and I can pick and choose manually any other settings I see in the output file that I want to restore this way and remove some of the toil of upgrading appropriately.

I also see in the developer tools in the browser, the nvram names for settings are pretty closely matched to the UI input fields, so I should be able to build a list of the ones I'm the most interested in and only restore those to a freshly installed firmware and leave the rest as they came.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions 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