Resetting corrupted config file

My x86 device running 18.06 was hit by a power failure. It came back with lots of ext4 errors on the syslog. I ran e2fsck which found a deleted inode in /etc/config/dhcp, so I no longer had that file.

However, with that file missing, LuCI no longer displayed the "DHCP Server" section on any interface, and the "DHCP and DNS" page was missing as well. Creating a blank file restored these sections, but the "Server Settings" on "DHCP and DNS" were still missing; and after reconfiguring DHCP on the lan interface, my network still had no DNS. Eventually I logged in to my Wi-Fi bridge and copied its unused /etc/config/dhcp over, and everything started working again.

My question is: what would be the best solution (short of a reflash) to restore a single config file to its defaults?

1 Like

There are two kinds of default config files:

  • those in the squashfs rootfs (/etc/config/firewall, /etc/config/dhcp)
  • those dynamically created after probing the hardware on firstboot (/etc/config/wireless, parts of /etc/config/network)

The first kind are easily obtained by booting into recovery mode.

No need to go into recovery mode. You can simply copy the original dhcp configuration file from /rom/etc/config

The static default configuration files included in the firmware image are there.

(dynamically created files like system and network are not there, but most other configuration files are there.)

This is an x86 device with RW ext4 root filesystem, there is no /rom structure.

root@OpenWrt:~# ls /rom
root@OpenWrt:~# cat /rom/note
After firstboot has been run, / will be jffs2 and /rom will be squashfs
(* except when in failsafe)

If you have the image file you can extract files from it using for instance 7zip.

opkg update
opkg --force-reinstall install dnsmasq
cat /etc/config/dhcp-opkg

that should work.
Opkg installs the default configuration file as reference as dhcp-opkg but will not overwrite the existing configuration file.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.