[Solved] Recovering an alternate default configuration even resetting

Hello
It is very common to reset a device and reconfigure it completely again.
I would like to know if it's possible to make a personalized configuration and then convert this configuration in the default configuration, so when I reset the device continue having my configuration. For example copying "network", "wireless" and other files to another directory, or puting the contents of these files in another files containing the real default configuration.
Or at least to save the personalized configuration on device as Mikrotik do.

TIA

Take a look at full MTD backup and configuration backup...

https://wiki.openwrt.org/doc/howto/generic.backup

Create a custom image either with Image Builder (very easy) or compile your own. I believe the network config is created on the first run (at least I don't see it in /rom/etc/config/ on my router), but you can use uci-defaults scripts as well to customize your image.

2 Likes

/etc/config/network, as well as a few others, are created upon first boot.

I recommend the following directories and files to backup, depending on how one's environment is configured:

####################################################
            ##----- Directories -----##
####################################################

/etc/config/
/etc/crontabs/
/etc/mc/
/etc/openvpn/
/etc/samba/
/etc/ssh/
/etc/ssl/
/root/
/usr/share/nano/
/www/

####################################################
               ##----- Files -----##
####################################################

/etc/banner.failsafe
/etc/banner.security
/etc/collectd.conf
/etc/firewall.user
/etc/group
/etc/inputrc
/etc/passwd
/etc/profile
/etc/rc.local
/etc/shadow
/etc/smartd.conf
/etc/sudoers
/etc/sysupgrade.conf
  • I've customized the css for the material theme, hence the /www/ directory

If one will be compiling their own image, copy the above to the system your buildroot is on and customize accordingly.

  1. Build System Installation
    • I created a script that performs this automatically for Ubuntu, however prior to compiling (either before running the script, or when menuconfig is ran), the user will need to add the buildroot toolchain to their PATH
  2. Build System Usage

Hi
Thank you all. I was thinking this was more easy. I'm not an expert on Linux to build my own images.
Anyway I can make a backup file from Luci for every device but... my idea was that when a user reset a router, the router read the default configuration from somewhere ( a file suppose), so if I change the parameters in the file that contains the default configuration, the new data introduced by me in that file will be the new default configuration, till I update the firmware again. I only want to know if this is possible, and how.

TIA

There is no file with defaults. OpenWrt has the concept of an overlay filesystem on top of a highly compressed read only filesystem image. There is no way to change this read only image without rebuilding it from scratch.

Compiling LEDE is one of the easiest things, especially if you utilize the script I referenced above.

  • Ubuntu does not need to be physically installed, but can be ran either as a Live Boot USB or within a VM
    • The only thing you will need to do is:
      • Place the toolchain path in your ~/.bashrc's PATH in Ubuntu once the buildroot has been installed
        • You can do this once the script loads menuconfig
        • I'm currently working on an improved version of my script which will automate this
      • Create a folder named files in your buildboot (directory is named source, and treat this (./source/files/) as if it's the root of your router's file system (i.e. /)
        • For example, your configs at /etc/config on your router will go in the same folder hierarchy within files (i.e. ./source/files/etc/config)

Depending on your processor, and how many packages you select to install within menuconfig, compiling could take an hour or two or half a day.

  • Package info can be obtained for some packages/options within menuconfig, else you can see details about a package via LEDE's Package Table

Hello all
Thanks for your information. One of these days I will have to learn to build my own images.
The problem as ever... time to do it.
Thanks