Skip to content

Saving files permanently

Adam edited this page Jan 13, 2019 · 1 revision

Updating configuration

Updating /etc/config

XML files method

If you don't have access to root console, you can perform these steps to update some OpenWrt configuration. This stores the changes permanently (will remain after reboot)

  • go to router web interface and perform Backup
  • use bin2xml script to convert downloaded binary config to xml file (scripts are here)
  • edit xml file per your needs (be careful with xml structure!)
  • use xml2bin to convert the xml back to bin file
  • use Restore function on your router web interface to upload new config

uci method

Once you have access to your console, you can use uci to upate your configuration. However, this change is not permanent (Actually it might be, read below…). Example:

uci set openvpn.server.verbose=4
uci commit

Note: if you reboot your router now, your changes will be lost.

Saving configuration

Backup/Restore method

Once you edit your changes with uci and want to persist it, you can just go to your web interface and use Backup to download binary config, and follow immediately by using Restore function to upload exactly the same config. Router will persist your changes and reboot.

lua script

As mentioned above, uci might save the changes. To explain it, see below:

root@AC2300:~# crontab -l
0 3 * * * lua -e 'require("luci.sys.config").saveconfig()'
* * * * * /bin/sh /etc/hotplug.d/iface/99-wportal

it means that everyday at 3am firmware calls lua -e 'require("luci.sys.config").saveconfig()'. Actually - this is the command to persist your configuration. And no reboot required :)

Saving files in /

If you want to permanently save some files in /, you need to remount your root in read-write mode:

mount / -o rw,remount

Saving other files in /etc

You have access to /etc/ in rw mode, but beware. This folder is mounted in ramfs. During router startup, the original /etc is copied into ram-enabled filesystem. However, you can access the original /etc by mounting it with bind option.

Perform the commands below. It will remount / as read-write, and mount original / in /tmp/root. You can then go to /tmp/root/etc to update your files. Once you're done, reboot the router and you'll see your changes persisted under /etc. Note: most likely you can't modify most of /etc/config files directly this way, as these will be overwritten from nvram during boot procedure.

mkdir -p /tmp/root
mount / -o rw,remount
mount / -o bind /tmp/root